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

Function default_calloc

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

The default data mem allocator calloc routine does not make use of a ctx. It should be called only through PyDataMem_UserNEW_ZEROED since itself does not handle eventhook and tracemalloc logic.

Source from the content-addressed store, hash-verified

374// It should be called only through PyDataMem_UserNEW_ZEROED
375// since itself does not handle eventhook and tracemalloc logic.
376static inline void *
377default_calloc(void *NPY_UNUSED(ctx), size_t nelem, size_t elsize)
378{
379 void * p;
380 size_t sz = nelem * elsize;
381 NPY_BEGIN_THREADS_DEF;
382 if (sz < NBUCKETS) {
383 p = _npy_alloc_cache(sz, 1, NBUCKETS, datacache, &malloc);
384 if (p) {
385 memset(p, 0, sz);
386 }
387 return p;
388 }
389 NPY_BEGIN_THREADS;
390 p = calloc(nelem, elsize);
391 NPY_END_THREADS;
392 return p;
393}
394
395// The default data mem allocator realloc routine does not make use of a ctx.
396// It should be called only through PyDataMem_UserRENEW

Callers

nothing calls this directly

Calls 1

_npy_alloc_cacheFunction · 0.85

Tested by

no test coverage detected