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. */
| 533 | * memory management callback hooks. |
| 534 | */ |
| 535 | NPY_NO_EXPORT PyObject * |
| 536 | PyDataMem_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 |
nothing calls this directly
no outgoing calls
no test coverage detected