Numarray und NA_NewAll

Discussion in 'Python' started by Marco Bubke, Jan 21, 2004.

  1. Marco Bubke

    Marco Bubke Guest

    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
    Marco Bubke, Jan 21, 2004
    #1
    1. Advertising

  2. Marco Bubke

    Marco Bubke Guest

    Sorry, little stupid bug is in the it. It must be tUInt8.
    Marco Bubke, Jan 21, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. RJS
    Replies:
    0
    Views:
    470
  2. Tim Rowe

    Numarray for Python 2.3

    Tim Rowe, Jul 16, 2003, in forum: Python
    Replies:
    2
    Views:
    339
    Tim Rowe
    Jul 16, 2003
  3. Thomas Heller

    Re: py2exe and numarray

    Thomas Heller, Aug 8, 2003, in forum: Python
    Replies:
    0
    Views:
    394
    Thomas Heller
    Aug 8, 2003
  4. Eugene Druker

    numarray.linear_algebra.eigenvectors bug ?

    Eugene Druker, Sep 19, 2003, in forum: Python
    Replies:
    1
    Views:
    337
    John J. Lee
    Sep 20, 2003
  5. Colin J. Williams

    Sub-classing NumArray - two questions

    Colin J. Williams, Oct 1, 2003, in forum: Python
    Replies:
    0
    Views:
    271
    Colin J. Williams
    Oct 1, 2003
Loading...

Share This Page