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

Function PyArray_ClearBuffer

numpy/core/src/multiarray/refcount.c:35–56  ·  view source on GitHub ↗

* Helper function to clear a strided memory (normally or always contiguous) * from all Python (or other) references. The function does nothing if the * array dtype does not indicate holding references. * * It is safe to call this function more than once, failing here is usually * critical (during cleanup) and should be set up to minimize the risk or * avoid it fully. */

Source from the content-addressed store, hash-verified

33 * avoid it fully.
34 */
35NPY_NO_EXPORT int
36PyArray_ClearBuffer(
37 PyArray_Descr *descr, char *data,
38 npy_intp stride, npy_intp size, int aligned)
39{
40 if (!PyDataType_REFCHK(descr)) {
41 return 0;
42 }
43
44 NPY_traverse_info clear_info;
45 /* Flags unused: float errors do not matter and we do not release GIL */
46 NPY_ARRAYMETHOD_FLAGS flags_unused;
47 if (PyArray_GetClearFunction(
48 aligned, stride, descr, &clear_info, &flags_unused) < 0) {
49 return -1;
50 }
51
52 int res = clear_info.func(
53 NULL, clear_info.descr, data, size, stride, clear_info.auxdata);
54 NPY_traverse_info_xfree(&clear_info);
55 return res;
56}
57
58
59/*

Callers 4

_new_sortlikeFunction · 0.85
_new_argsortlikeFunction · 0.85
PyArray_ClearArrayFunction · 0.85
PyArray_FillWithScalarFunction · 0.85

Calls 3

PyArray_GetClearFunctionFunction · 0.85
NPY_traverse_info_xfreeFunction · 0.85
funcMethod · 0.45

Tested by

no test coverage detected