Permalink
Browse files

BLD: MSVC build fix for switch of PyArray_DATA to void*

Build errors because void* doesn't have a size, so
adding an offset to it is disallowed.
  • Loading branch information...
1 parent d8370da commit c97f405d47d059c00df6b2aea7f79fc5c520dda6 @mwiebe mwiebe committed Dec 6, 2012
@@ -583,7 +583,7 @@ index2ptr(PyArrayObject *mp, npy_intp i)
if (i == 0) {
return PyArray_DATA(mp);
}
- return PyArray_DATA(mp)+i*PyArray_STRIDES(mp)[0];
+ return PyArray_BYTES(mp)+i*PyArray_STRIDES(mp)[0];
}
NPY_NO_EXPORT int
@@ -443,7 +443,7 @@ setArrayFromSequence(PyArrayObject *a, PyObject *s,
}
else {
res = PyArray_DESCR(a)->f->setitem(o,
- (PyArray_DATA(a) + offset), a);
+ (PyArray_BYTES(a) + offset), a);
}
if (res < 0) {
Py_DECREF(o);
@@ -465,7 +465,7 @@ setArrayFromSequence(PyArrayObject *a, PyObject *s,
}
else {
res = PyArray_DESCR(a)->f->setitem(o,
- (PyArray_DATA(a) + offset), a);
+ (PyArray_BYTES(a) + offset), a);
}
Py_DECREF(o);
if (res < 0) {
@@ -138,7 +138,7 @@ array_strides_set(PyArrayObject *self, PyObject *obj)
PyErr_Clear();
numbytes = PyArray_MultiplyList(PyArray_DIMS(new),
PyArray_NDIM(new))*PyArray_DESCR(new)->elsize;
- offset = PyArray_DATA(self) - PyArray_DATA(new);
+ offset = PyArray_BYTES(self) - PyArray_BYTES(new);
}
if (!PyArray_CheckStrides(PyArray_DESCR(self)->elsize, PyArray_NDIM(self), numbytes,
@@ -666,7 +666,7 @@ _get_part(PyArrayObject *self, int imag)
PyArray_NDIM(self),
PyArray_DIMS(self),
PyArray_STRIDES(self),
- PyArray_DATA(self) + offset,
+ PyArray_BYTES(self) + offset,
PyArray_FLAGS(self), (PyObject *)self);
if (ret == NULL) {
return NULL;
@@ -252,7 +252,7 @@ PyArray_PutTo(PyArrayObject *self, PyObject* values0, PyObject *indices0,
switch(clipmode) {
case NPY_RAISE:
for (i = 0; i < ni; i++) {
- src = PyArray_DATA(values) + chunk*(i % nv);
+ src = PyArray_BYTES(values) + chunk*(i % nv);
tmp = ((npy_intp *)(PyArray_DATA(indices)))[i];
if (check_and_adjust_index(&tmp, max_item, 0) < 0) {
goto fail;
@@ -264,7 +264,7 @@ PyArray_PutTo(PyArrayObject *self, PyObject* values0, PyObject *indices0,
break;
case NPY_WRAP:
for (i = 0; i < ni; i++) {
- src = PyArray_DATA(values) + chunk * (i % nv);
+ src = PyArray_BYTES(values) + chunk * (i % nv);
tmp = ((npy_intp *)(PyArray_DATA(indices)))[i];
if (tmp < 0) {
while (tmp < 0) {
@@ -283,7 +283,7 @@ PyArray_PutTo(PyArrayObject *self, PyObject* values0, PyObject *indices0,
break;
case NPY_CLIP:
for (i = 0; i < ni; i++) {
- src = PyArray_DATA(values) + chunk * (i % nv);
+ src = PyArray_BYTES(values) + chunk * (i % nv);
tmp = ((npy_intp *)(PyArray_DATA(indices)))[i];
if (tmp < 0) {
tmp = 0;
@@ -302,7 +302,7 @@ PyArray_PutTo(PyArrayObject *self, PyObject* values0, PyObject *indices0,
switch(clipmode) {
case NPY_RAISE:
for (i = 0; i < ni; i++) {
- src = PyArray_DATA(values) + chunk * (i % nv);
+ src = PyArray_BYTES(values) + chunk * (i % nv);
tmp = ((npy_intp *)(PyArray_DATA(indices)))[i];
if (check_and_adjust_index(&tmp, max_item, 0) < 0) {
goto fail;
@@ -312,7 +312,7 @@ PyArray_PutTo(PyArrayObject *self, PyObject* values0, PyObject *indices0,
break;
case NPY_WRAP:
for (i = 0; i < ni; i++) {
- src = PyArray_DATA(values) + chunk * (i % nv);
+ src = PyArray_BYTES(values) + chunk * (i % nv);
tmp = ((npy_intp *)(PyArray_DATA(indices)))[i];
if (tmp < 0) {
while (tmp < 0) {
@@ -329,7 +329,7 @@ PyArray_PutTo(PyArrayObject *self, PyObject* values0, PyObject *indices0,
break;
case NPY_CLIP:
for (i = 0; i < ni; i++) {
- src = PyArray_DATA(values) + chunk * (i % nv);
+ src = PyArray_BYTES(values) + chunk * (i % nv);
tmp = ((npy_intp *)(PyArray_DATA(indices)))[i];
if (tmp < 0) {
tmp = 0;
@@ -428,7 +428,7 @@ PyArray_PutMask(PyArrayObject *self, PyObject* values0, PyObject* mask0)
for (i = 0; i < ni; i++) {
tmp = ((npy_bool *)(PyArray_DATA(mask)))[i];
if (tmp) {
- src = PyArray_DATA(values) + chunk * (i % nv);
+ src = PyArray_BYTES(values) + chunk * (i % nv);
PyArray_Item_INCREF(src, PyArray_DESCR(self));
PyArray_Item_XDECREF(dest+i*chunk, PyArray_DESCR(self));
memmove(dest + i * chunk, src, chunk);
@@ -441,7 +441,7 @@ PyArray_PutMask(PyArrayObject *self, PyObject* values0, PyObject* mask0)
for (i = 0; i < ni; i++) {
tmp = ((npy_bool *)(PyArray_DATA(mask)))[i];
if (tmp) {
- src = PyArray_DATA(values) + chunk*(i % nv);
+ src = PyArray_BYTES(values) + chunk*(i % nv);
memmove(dest + i*chunk, src, chunk);
}
}
@@ -60,7 +60,7 @@ array_big_item(PyArrayObject *self, npy_intp i)
if (check_and_adjust_index(&i, dim0, 0) < 0) {
return NULL;
}
- item = PyArray_DATA(self) + i * PyArray_STRIDE(self, 0);
+ item = PyArray_BYTES(self) + i * PyArray_STRIDE(self, 0);
/* Create the view array */
Py_INCREF(PyArray_DESCR(self));
@@ -108,7 +108,7 @@ array_item_nice(PyArrayObject *self, Py_ssize_t _i)
if (check_and_adjust_index(&i, dim0, 0) < 0) {
return NULL;
}
- item = PyArray_DATA(self) + i * PyArray_STRIDE(self, 0);
+ item = PyArray_BYTES(self) + i * PyArray_STRIDE(self, 0);
return PyArray_Scalar(item, PyArray_DESCR(self), (PyObject *)self);
}
@@ -159,7 +159,7 @@ array_ass_big_item(PyArrayObject *self, npy_intp i, PyObject *v)
if (check_and_adjust_index(&i, dim0, 0) < 0) {
return -1;
}
- item = PyArray_DATA(self) + i * PyArray_STRIDE(self, 0);
+ item = PyArray_BYTES(self) + i * PyArray_STRIDE(self, 0);
return PyArray_DESCR(self)->f->setitem(v, item, self);
}
@@ -593,7 +593,7 @@ array_subscript_simple(PyArrayObject *self, PyObject *op)
ret = (PyArrayObject *)PyArray_NewFromDescr(Py_TYPE(self),
PyArray_DESCR(self),
nd, dimensions,
- strides, PyArray_DATA(self) + offset,
+ strides, PyArray_BYTES(self) + offset,
PyArray_FLAGS(self),
(PyObject *)self);
if (ret == NULL) {
@@ -372,7 +372,7 @@ PyArray_GetField(PyArrayObject *self, PyArray_Descr *typed, int offset)
typed,
PyArray_NDIM(self), PyArray_DIMS(self),
PyArray_STRIDES(self),
- PyArray_DATA(self) + offset,
+ PyArray_BYTES(self) + offset,
PyArray_FLAGS(self)&(~NPY_ARRAY_F_CONTIGUOUS),
(PyObject *)self);
if (ret == NULL) {
@@ -427,7 +427,7 @@ PyArray_SetField(PyArrayObject *self, PyArray_Descr *dtype,
}
ret = PyArray_NewFromDescr(Py_TYPE(self),
dtype, PyArray_NDIM(self), PyArray_DIMS(self),
- PyArray_STRIDES(self), PyArray_DATA(self) + offset,
+ PyArray_STRIDES(self), PyArray_BYTES(self) + offset,
PyArray_FLAGS(self), (PyObject *)self);
if (ret == NULL) {
return -1;
@@ -82,7 +82,7 @@ static int copy_object(PyArrayIterObject *itx, PyArrayNeighborhoodIterObject *ni
}
for (j = 0; j < niterx->size; ++j) {
- copyswap(PyArray_DATA(aout) + j * itemsize, niterx->dataptr, 0, NULL);
+ copyswap(PyArray_BYTES(aout) + j * itemsize, niterx->dataptr, 0, NULL);
PyArrayNeighborhoodIter_Next(niterx);
}
@@ -208,7 +208,7 @@ PyArray_AsCArray(PyObject **op, void *ptr, npy_intp *dims, int nd,
goto fail;
}
for (i = 0; i < n; i++) {
- ptr2[i] = PyArray_DATA(ap) + i*PyArray_STRIDES(ap)[0];
+ ptr2[i] = PyArray_BYTES(ap) + i*PyArray_STRIDES(ap)[0];
}
*((char ***)ptr) = ptr2;
break;
@@ -222,7 +222,7 @@ PyArray_AsCArray(PyObject **op, void *ptr, npy_intp *dims, int nd,
for (i = 0; i < n; i++) {
ptr3[i] = ptr3[n + (m-1)*i];
for (j = 0; j < m; j++) {
- ptr3[i][j] = PyArray_DATA(ap) + i*PyArray_STRIDES(ap)[0] + j*PyArray_STRIDES(ap)[1];
+ ptr3[i][j] = PyArray_BYTES(ap) + i*PyArray_STRIDES(ap)[0] + j*PyArray_STRIDES(ap)[1];
}
}
*((char ****)ptr) = ptr3;
@@ -1172,7 +1172,7 @@ _pyarray_correlate(PyArrayObject *ap1, PyArrayObject *ap2, int typenum,
op = PyArray_DATA(ret);
os = PyArray_DESCR(ret)->elsize;
ip1 = PyArray_DATA(ap1);
- ip2 = PyArray_DATA(ap2) + n_left*is2;
+ ip2 = PyArray_BYTES(ap2) + n_left*is2;
n = n - n_left;
for (i = 0; i < n_left; i++) {
dot(ip1, is1, ip2, is2, op, n, ret);
@@ -120,7 +120,7 @@ PyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape, int refcheck,
if (PyDataType_FLAGCHK(PyArray_DESCR(self), NPY_ITEM_REFCOUNT)) {
PyObject *zero = PyInt_FromLong(0);
char *optr;
- optr = PyArray_DATA(self) + oldsize*elsize;
+ optr = PyArray_BYTES(self) + oldsize*elsize;
n = newsize - oldsize;
for (k = 0; k < n; k++) {
_putzero((char *)optr, zero, PyArray_DESCR(self));
@@ -129,7 +129,7 @@ PyArray_Resize(PyArrayObject *self, PyArray_Dims *newshape, int refcheck,
Py_DECREF(zero);
}
else{
- memset(PyArray_DATA(self)+oldsize*elsize, 0, (newsize-oldsize)*elsize);
+ memset(PyArray_BYTES(self)+oldsize*elsize, 0, (newsize-oldsize)*elsize);
}
}

0 comments on commit c97f405

Please sign in to comment.