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

Function PyDataMem_SetHandler

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

NUMPY_API * Set a new allocation policy. If the input value is NULL, will reset * the policy to the default. Return the previous policy, or * return NULL if an error has occurred. We wrap the user-provided * functions so they will still call the python and numpy * memory management callback hooks. */

Source from the content-addressed store, hash-verified

533 * memory management callback hooks.
534 */
535NPY_NO_EXPORT PyObject *
536PyDataMem_SetHandler(PyObject *handler)
537{
538 PyObject *old_handler;
539 PyObject *token;
540 if (PyContextVar_Get(current_handler, NULL, &old_handler)) {
541 return NULL;
542 }
543 if (handler == NULL) {
544 handler = PyDataMem_DefaultHandler;
545 }
546 token = PyContextVar_Set(current_handler, handler);
547 if (token == NULL) {
548 Py_DECREF(old_handler);
549 return NULL;
550 }
551 Py_DECREF(token);
552 return old_handler;
553}
554
555/*NUMPY_API
556 * Return the policy that will be used to allocate data

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected