Numarray und NA_NewAll

M

Marco Bubke

Hi

If I understand the code right then there will be mset called if buffer is
NULL. Why?

I want only a empty array, why not a malloc? The data section after that
will be overwritten by me. Maybe I'm wrong.



static PyArrayObject *
NA_NewAll(int ndim, maybelong *shape, NumarrayType type,
void *buffer, maybelong byteoffset, maybelong bytestride,
int byteorder, int aligned, int writeable)
{
PyArrayObject *result = NA_NewAllFromBuffer(
ndim, shape, type, Py_None, byteoffset, bytestride,
byteorder, aligned, writeable);

if (result) {
if (!NA_NumArrayCheck((PyObject *) result)) {
PyErr_Format( PyExc_TypeError,
"NA_NewAll: non-NumArray result");
result = NULL;
} else {
if (buffer) {
memcpy(result->data, buffer,
PyArray_NBYTES(result));
} else {
memset(result->data, 0,
PyArray_NBYTES(result)); <-- ??????????????????
}
}
}
return result;
}

def get_polygon_stipple():
"""Return the polygon stipple pattern"""
cdef maybelong lenght
cdef void** data
lenght = 128
new_array = NA_NewArray(NULL, tUInt32, 1, lenght)
glGetPolygonStipple(<GLubyte*>NA_OFFSETDATA(new_array))
assert glGetError() != INVALID_OPERATION,\
"can't be called between gl.begin() and gl.end()"
return new_array

Here my code. I'm not sure if this is possible? I have also found
NA_getBufferPtrAndSize? Should I use this?

regards

Marco
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top