MCPcopy Create free account
hub / github.com/defold/defold / calloc

Function calloc

engine/dlib/src/dlib/memprofile.cpp:513–553  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

511
512extern "C"
513DM_DLLEXPORT void *calloc(size_t count, size_t size)
514{
515 if (!callocp)
516 {
517 CreateHooks();
518 }
519
520 void *ptr = callocp(count, size);
521
522 if (ptr)
523 {
524 size_t usable_size = 0;
525#if defined(__linux__)
526 usable_size = malloc_usable_size(ptr);
527#elif defined(__MACH__)
528 usable_size = malloc_size(ptr);
529#else
530#error "Unsupported platform"
531#endif
532
533 dmMemProfile::DumpBacktrace('M', ptr, usable_size);
534
535 if (dmMemProfile::g_ExtStats)
536 {
537 dmAtomicAdd32(&dmMemProfile::g_ExtStats->m_TotalAllocated, (uint32_t) usable_size);
538 dmAtomicAdd32(&dmMemProfile::g_ExtStats->m_TotalActive, (uint32_t) usable_size);
539 dmAtomicAdd32(&dmMemProfile::g_ExtStats->m_AllocationCount, 1U);
540
541 if (dmMemProfile::m_PropertyAddU32)
542 {
543 dmMemProfile::m_PropertyAddU32(dmMemProfile::g_ProfileAllocations, 1U);
544 dmMemProfile::m_PropertyAddU32(dmMemProfile::g_ProfileAmount, usable_size);
545 }
546 }
547 }
548 else
549 {
550 dmMemProfile::DumpBacktrace('M', 0, 0);
551 }
552 return ptr;
553}
554
555extern "C"
556DM_DLLEXPORT void *realloc(void* ptr, size_t size)

Callers 15

PlatformInitFunction · 0.85
make_clistMethod · 0.85
ResamplerMethod · 0.85
opencl_create_contextFunction · 0.85
zip_strcloneFunction · 0.85
zip_strrplFunction · 0.85
zip_entry_finalizeFunction · 0.85
zip_files_moveFunction · 0.85
zip_entries_delete_markFunction · 0.85
zip_openwitherrorFunction · 0.85
zip_entries_deleteFunction · 0.85

Calls 3

CreateHooksFunction · 0.85
DumpBacktraceFunction · 0.85
dmAtomicAdd32Function · 0.85

Tested by 3

TESTFunction · 0.68
add_pair_pos_2Function · 0.68