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

Method on_malloc

tests/profile/json_memory_profile.cpp:60–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58 }
59
60 void on_malloc(void* ptr, size_t size) {
61 if (!ptr) return;
62
63 // Use fetch_add instead of += for fl::atomic
64 current_bytes.fetch_add(size);
65 total_allocated.fetch_add(size);
66 alloc_count.fetch_add(1);
67
68 // Update peak
69 size_t curr = current_bytes.load();
70 size_t peak = peak_bytes.load();
71 while (curr > peak && !peak_bytes.compare_exchange_weak(peak, curr)) {
72 peak = peak_bytes.load();
73 }
74
75 // Track allocation
76 allocations[ptr] = static_cast<u32>(size);
77 }
78
79 void on_free(void* ptr) {
80 if (!ptr) return;

Callers 3

mallocFunction · 0.80
callocFunction · 0.80
reallocFunction · 0.80

Calls 3

fetch_addMethod · 0.45
loadMethod · 0.45
compare_exchange_weakMethod · 0.45

Tested by

no test coverage detected