MCPcopy Create free account
hub / github.com/numpy/numpy / PyDataMem_UserRENEW

Function PyDataMem_UserRENEW

numpy/core/src/multiarray/alloc.c:501–526  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

499}
500
501NPY_NO_EXPORT void *
502PyDataMem_UserRENEW(void *ptr, size_t size, PyObject *mem_handler)
503{
504 void *result;
505 PyDataMem_Handler *handler = (PyDataMem_Handler *) PyCapsule_GetPointer(mem_handler, "mem_handler");
506 if (handler == NULL) {
507 return NULL;
508 }
509
510 assert(size != 0);
511 result = handler->allocator.realloc(handler->allocator.ctx, ptr, size);
512 if (result != ptr) {
513 PyTraceMalloc_Untrack(NPY_TRACE_DOMAIN, (npy_uintp)ptr);
514 }
515 PyTraceMalloc_Track(NPY_TRACE_DOMAIN, (npy_uintp)result, size);
516 if (_PyDataMem_eventhook != NULL) {
517 NPY_ALLOW_C_API_DEF
518 NPY_ALLOW_C_API
519 if (_PyDataMem_eventhook != NULL) {
520 (*_PyDataMem_eventhook)(ptr, result, size,
521 _PyDataMem_eventhook_user_data);
522 }
523 NPY_DISABLE_C_API
524 }
525 return result;
526}
527
528/*NUMPY_API
529 * Set a new allocation policy. If the input value is NULL, will reset

Callers 5

array_from_textFunction · 0.85
PyArray_FromFileFunction · 0.85
PyArray_FromIterFunction · 0.85
PyArray_ResizeFunction · 0.85
read_rowsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected