*/
static PyObject *interned;
-
/*
For both PyString_FromString() and PyString_FromStringAndSize(), the
parameter `size' denotes number of characters to allocate, not counting any
op->ob_shash = -1;
op->ob_sstate = SSTATE_NOT_INTERNED;
if (str != NULL)
- memcpy(op->ob_sval, str, size);
+ Py_MEMCPY(op->ob_sval, str, size);
op->ob_sval[size] = '\0';
/* share short strings */
if (size == 0) {
PyObject_INIT_VAR(op, &PyString_Type, size);
op->ob_shash = -1;
op->ob_sstate = SSTATE_NOT_INTERNED;
- memcpy(op->ob_sval, str, size+1);
+ Py_MEMCPY(op->ob_sval, str, size+1);
/* share short strings */
if (size == 0) {
PyObject *t = (PyObject *)op;
PyObject* string;
#ifdef VA_LIST_IS_ARRAY
- memcpy(count, vargs, sizeof(va_list));
+ Py_MEMCPY(count, vargs, sizeof(va_list));
#else
#ifdef __va_copy
__va_copy(count, vargs);
i = strlen(p);
if (n > 0 && i > n)
i = n;
- memcpy(s, p, i);
+ Py_MEMCPY(s, p, i);
s += i;
break;
case 'p':
assert(PyString_Check(w));
r = PyString_AS_STRING(w);
rn = PyString_GET_SIZE(w);
- memcpy(p, r, rn);
+ Py_MEMCPY(p, r, rn);
p += rn;
Py_DECREF(w);
s = t;
PyObject_INIT_VAR(op, &PyString_Type, size);
op->ob_shash = -1;
op->ob_sstate = SSTATE_NOT_INTERNED;
- memcpy(op->ob_sval, a->ob_sval, a->ob_size);
- memcpy(op->ob_sval + a->ob_size, b->ob_sval, b->ob_size);
+ Py_MEMCPY(op->ob_sval, a->ob_sval, a->ob_size);
+ Py_MEMCPY(op->ob_sval + a->ob_size, b->ob_sval, b->ob_size);
op->ob_sval[size] = '\0';
return (PyObject *) op;
#undef b
}
i = 0;
if (i < size) {
- memcpy(op->ob_sval, a->ob_sval, a->ob_size);
+ Py_MEMCPY(op->ob_sval, a->ob_sval, a->ob_size);
i = a->ob_size;
}
while (i < size) {
j = (i <= size-i) ? i : size-i;
- memcpy(op->ob_sval+i, op->ob_sval, j);
+ Py_MEMCPY(op->ob_sval+i, op->ob_sval, j);
i += j;
}
return (PyObject *) op;
size_t n;
item = PySequence_Fast_GET_ITEM(seq, i);
n = PyString_GET_SIZE(item);
- memcpy(p, PyString_AS_STRING(item), n);
+ Py_MEMCPY(p, PyString_AS_STRING(item), n);
p += n;
if (i < seqlen - 1) {
- memcpy(p, sep, seplen);
+ Py_MEMCPY(p, sep, seplen);
p += seplen;
}
}
Py_ssize_t sub_len;
Py_ssize_t start=0, end=PY_SSIZE_T_MAX;
- /* XXX ssize_t i */
if (!PyArg_ParseTuple(args, "O|O&O&:find/rfind/index/rindex", &subobj,
_PyEval_SliceIndex, &start, _PyEval_SliceIndex, &end))
return -2;
(PyObject *)self, subobj, start, end, dir);
#endif
else if (PyObject_AsCharBuffer(subobj, &sub, &sub_len))
+ /* XXX - the "expected a character buffer object" is pretty
+ confusing for a non-expert. remap to something else ? */
return -2;
if (dir > 0)
s = PyString_AS_STRING(newobj);
- memcpy(s, PyString_AS_STRING(self), n);
+ Py_MEMCPY(s, PyString_AS_STRING(self), n);
for (i = 0; i < n; i++) {
int c = Py_CHARMASK(s[i]);
s = PyString_AS_STRING(newobj);
- memcpy(s, PyString_AS_STRING(self), n);
+ Py_MEMCPY(s, PyString_AS_STRING(self), n);
for (i = 0; i < n; i++) {
int c = Py_CHARMASK(s[i]);
/* TODO: special case single character, which doesn't need memcpy */
/* Lay the first one down (guaranteed this will occur) */
- memcpy(result_s, to_s, to_len);
+ Py_MEMCPY(result_s, to_s, to_len);
result_s += to_len;
count -= 1;
for (i=0; i<count; i++) {
*result_s++ = *self_s++;
- memcpy(result_s, to_s, to_len);
+ Py_MEMCPY(result_s, to_s, to_len);
result_s += to_len;
}
/* Copy the rest of the original string */
- memcpy(result_s, self_s, self_len-i);
+ Py_MEMCPY(result_s, self_s, self_len-i);
return result;
}
next = findchar(start, end-start, from_c);
if (next == NULL)
break;
- memcpy(result_s, start, next-start);
+ Py_MEMCPY(result_s, start, next-start);
result_s += (next-start);
start = next+1;
}
- memcpy(result_s, start, end-start);
+ Py_MEMCPY(result_s, start, end-start);
return result;
}
break;
next = start + offset;
- memcpy(result_s, start, next-start);
+ Py_MEMCPY(result_s, start, next-start);
result_s += (next-start);
start = next+from_len;
}
- memcpy(result_s, start, end-start);
+ Py_MEMCPY(result_s, start, end-start);
return result;
}
if (result == NULL)
return NULL;
result_s = PyString_AS_STRING(result);
- memcpy(result_s, self_s, self_len);
+ Py_MEMCPY(result_s, self_s, self_len);
/* change everything in-place, starting with this one */
start = result_s + (next-self_s);
if (result == NULL)
return NULL;
result_s = PyString_AS_STRING(result);
- memcpy(result_s, self_s, self_len);
+ Py_MEMCPY(result_s, self_s, self_len);
/* change everything in-place, starting with this one */
start = result_s + offset;
- memcpy(start, to_s, from_len);
+ Py_MEMCPY(start, to_s, from_len);
start += from_len;
end = result_s + self_len;
0, end-start, FORWARD);
if (offset==-1)
break;
- memcpy(start+offset, to_s, from_len);
+ Py_MEMCPY(start+offset, to_s, from_len);
start += offset+from_len;
}
if (next == start) {
/* replace with the 'to' */
- memcpy(result_s, to_s, to_len);
+ Py_MEMCPY(result_s, to_s, to_len);
result_s += to_len;
start += 1;
} else {
/* copy the unchanged old then the 'to' */
- memcpy(result_s, start, next-start);
+ Py_MEMCPY(result_s, start, next-start);
result_s += (next-start);
- memcpy(result_s, to_s, to_len);
+ Py_MEMCPY(result_s, to_s, to_len);
result_s += to_len;
start = next+1;
}
}
/* Copy the remainder of the remaining string */
- memcpy(result_s, start, end-start);
+ Py_MEMCPY(result_s, start, end-start);
return result;
}
next = start+offset;
if (next == start) {
/* replace with the 'to' */
- memcpy(result_s, to_s, to_len);
+ Py_MEMCPY(result_s, to_s, to_len);
result_s += to_len;
start += from_len;
} else {
/* copy the unchanged old then the 'to' */
- memcpy(result_s, start, next-start);
+ Py_MEMCPY(result_s, start, next-start);
result_s += (next-start);
- memcpy(result_s, to_s, to_len);
+ Py_MEMCPY(result_s, to_s, to_len);
result_s += to_len;
start = next+from_len;
}
}
/* Copy the remainder of the remaining string */
- memcpy(result_s, start, end-start);
+ Py_MEMCPY(result_s, start, end-start);
return result;
}
if (u) {
if (left)
memset(PyString_AS_STRING(u), fill, left);
- memcpy(PyString_AS_STRING(u) + left,
+ Py_MEMCPY(PyString_AS_STRING(u) + left,
PyString_AS_STRING(self),
PyString_GET_SIZE(self));
if (right)
n = PyString_GET_SIZE(tmp);
pnew = type->tp_alloc(type, n);
if (pnew != NULL) {
- memcpy(PyString_AS_STRING(pnew), PyString_AS_STRING(tmp), n+1);
+ Py_MEMCPY(PyString_AS_STRING(pnew), PyString_AS_STRING(tmp), n+1);
((PyStringObject *)pnew)->ob_shash =
((PyStringObject *)tmp)->ob_shash;
((PyStringObject *)pnew)->ob_sstate = SSTATE_NOT_INTERNED;
*res++ = *pbuf++;
}
}
- memcpy(res, pbuf, len);
+ Py_MEMCPY(res, pbuf, len);
res += len;
rescnt -= len;
while (--width >= len) {