regression was introduced recently with the introduction of the new "calloc"
functions (PyMem_RawCalloc, PyMem_Calloc, PyObject_Calloc).
Add also a unit test to check for the non-regression.
PyMemAllocator *alloc = (PyMemAllocator *)ctx;
void *ptr;
- assert(nelem <= PY_SIZE_MAX / elsize);
- ptr = alloc->malloc(alloc->ctx, size);
++ assert(elsize == 0 || nelem <= PY_SIZE_MAX / elsize);
+
+ if (use_calloc)
+ ptr = alloc->calloc(alloc->ctx, nelem, elsize);
+ else
+ ptr = alloc->malloc(alloc->ctx, nelem * elsize);
if (ptr == NULL)
return NULL;