| 499 | } |
| 500 | |
| 501 | NPY_NO_EXPORT void * |
| 502 | PyDataMem_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 |
no outgoing calls
no test coverage detected