MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / mspace_calloc

Function mspace_calloc

dlmalloc/dlmalloc.c:5049–5074  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5047}
5048
5049void* mspace_calloc(mspace msp, size_t n_elements, size_t elem_size) {
5050 void* mem;
5051 size_t req = 0, nb = 0;
5052 mstate ms = (mstate)msp;
5053 if (!ok_magic(ms)) {
5054 USAGE_ERROR_ACTION(ms,ms);
5055 return 0;
5056 }
5057 if (n_elements != 0) {
5058 req = n_elements * elem_size;
5059 if (((n_elements | elem_size) & ~(size_t)0xffff) &&
5060 (req / n_elements != elem_size))
5061 req = MAX_SIZE_T; /* force downstream failure on overflow */
5062 }
5063 if (!PREACTION(ms)) {
5064 mem = alloc_from_reserved_mem(ms, req, &nb);
5065 if (mem != NULL) {
5066 POSTACTION(ms);
5067 memset(mem, 0, req);
5068 } else {
5069 mem = sys_alloc(ms, nb, 1);
5070 POSTACTION(ms);
5071 }
5072 }
5073 return mem;
5074}
5075
5076static void* internal_mspace_realloc(mspace msp, void* oldmem, size_t bytes, int cpymem) {
5077 if (oldmem == 0)

Callers 4

comdb2ma_statsFunction · 0.85
comdb2_callocFunction · 0.85
get_areaFunction · 0.85
ma_pair_searchFunction · 0.85

Calls 2

alloc_from_reserved_memFunction · 0.85
sys_allocFunction · 0.85

Tested by

no test coverage detected