I have tracked it down to the following sample, which does also not work. In the debug version on windows, the PyObject_REALLOC fails with an assertion-error: _CrtIsValidHeapPointer(pUserData)
op = PyObject_NEW(PyClassObject, &PyClass_Type); op = PyObject_REALLOC(op, sizeof(PyClassObject) + 20);
Should the above work or am I doing something wrong?
Probably this doesn't work because of the GC header. The 'op' pointer does not point to the start of the allocated memory block. PyObject_NEW and friends know about this, but PyObject_REALLOC doesn't. That's what the assertion is trying to tell you.
Yes, I've also trakced it down to this.
I assume, PyObject_NEW is a friend of PyObject_DEL, and so are PyObject_MALLOC, PyObject_REALLOC, and PyObject_FREE - but the relationship between the first and the second category is somewhat cooler...
Is there any (official) way to realloc the memory returned by PyObject_NEW ?
(Always pushing the apis beyond their limits :-)