MCPcopy Create free account
hub / github.com/FastLED/FastLED / init_real_allocators

Function init_real_allocators

tests/profile/json_memory_profile.cpp:130–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

128FreeFunc real_free = nullptr;
129
130void init_real_allocators() {
131 if (real_malloc) return;
132
133 HMODULE ucrt = GetModuleHandleA("ucrtbase.dll");
134 if (!ucrt) ucrt = GetModuleHandleA("msvcrt.dll");
135
136 if (ucrt) {
137 real_malloc = (MallocFunc)GetProcAddress(ucrt, "malloc");
138 real_calloc = (CallocFunc)GetProcAddress(ucrt, "calloc");
139 real_realloc = (ReallocFunc)GetProcAddress(ucrt, "realloc");
140 real_free = (FreeFunc)GetProcAddress(ucrt, "free");
141 }
142
143 // If we can't find the real allocator, abort (can't fallback to malloc in override)
144 if (!real_malloc) {
145 printf("FATAL: Cannot find real malloc in ucrtbase.dll or msvcrt.dll\n");
146 abort();
147 }
148}
149#else
150void* real_malloc(size_t size) {
151 static auto fn = (void* (*)(size_t))dlsym(RTLD_NEXT, "malloc");

Callers 6

mallocFunction · 0.85
callocFunction · 0.85
reallocFunction · 0.85
freeFunction · 0.85
profile_json_memoryFunction · 0.85
test_phase1_validationFunction · 0.85

Calls 1

printfFunction · 0.85

Tested by 1

test_phase1_validationFunction · 0.68