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

Function calloc

db/memdebug.c:406–433  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

404}
405
406void *calloc(size_t nelem, size_t elsize) {
407 struct call *c;
408 struct memblock *b;
409 int size;
410 struct thread_info *ti;
411
412 init();
413 if (in_init)
414 return dl_calloc(nelem, elsize);
415
416 ti = get_thread_info();
417
418 size = nelem * elsize;
419 b = dl_malloc(offsetof(struct memblock, mem) + size);
420 b->flags = 0;
421 b->blocksize = size;
422 LOCK(&lk) {
423 c = get_call();
424 b->ti = ti;
425 b->place_allocated = c;
426 c->total_allocated += size;
427 listc_abl(&c->blocks, b);
428 listc_abl(&blocks, b);
429 listc_abl(&ti->blocks, b);
430 } UNLOCK(&lk);
431 bzero(b->mem, size);
432 return b->mem;
433}
434
435void free(void *ptr) {
436 struct call *c;

Callers 15

get_valFunction · 0.85
comdb2_register_printFunction · 0.85
tool_cdb2_printlog_mainFunction · 0.85
tool_cdb2_load_mainFunction · 0.85
client_thdFunction · 0.85
bdb_queue_init_privFunction · 0.85
retrieve_hostinfo_intFunction · 0.85
enque_udppfault_filepageFunction · 0.85
bdb_get_cursortranFunction · 0.85
sampler_initFunction · 0.85

Calls 6

dl_callocFunction · 0.85
dl_mallocFunction · 0.85
get_callFunction · 0.85
listc_ablFunction · 0.85
initFunction · 0.70
get_thread_infoFunction · 0.70

Tested by 8

create_tablesFunction · 0.68
run_testFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68
get_valFunction · 0.68
mainFunction · 0.68