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

Function npy_alloc_cache_zero

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

zero initialized data, sz is number of bytes to allocate */

Source from the content-addressed store, hash-verified

152
153/* zero initialized data, sz is number of bytes to allocate */
154NPY_NO_EXPORT void *
155npy_alloc_cache_zero(size_t nmemb, size_t size)
156{
157 void * p;
158 size_t sz = nmemb * size;
159 NPY_BEGIN_THREADS_DEF;
160 if (sz < NBUCKETS) {
161 p = _npy_alloc_cache(sz, 1, NBUCKETS, datacache, &PyDataMem_NEW);
162 if (p) {
163 memset(p, 0, sz);
164 }
165 return p;
166 }
167 NPY_BEGIN_THREADS;
168 p = PyDataMem_NEW_ZEROED(nmemb, size);
169 NPY_END_THREADS;
170 return p;
171}
172
173NPY_NO_EXPORT void
174npy_free_cache(void * p, npy_uintp sz)

Callers

nothing calls this directly

Calls 2

_npy_alloc_cacheFunction · 0.85
PyDataMem_NEW_ZEROEDFunction · 0.85

Tested by

no test coverage detected