| 98 | |
| 99 | #if defined(FASTLED_TESTING) |
| 100 | void SetMallocFreeHook(MallocFreeHook* hook) { |
| 101 | // Pre-initialize reentrancy counter to avoid recursive malloc during first hook call. |
| 102 | // On macOS, ThreadLocal uses pthread_setspecific which calls operator new, |
| 103 | // triggering recursive Malloc() that would corrupt the reentrancy counter. |
| 104 | (void)tls_reintrancy_count(); |
| 105 | |
| 106 | gMallocFreeHook = hook; |
| 107 | } |
| 108 | |
| 109 | void ClearMallocFreeHook() { |
| 110 | gMallocFreeHook = nullptr; |