MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cbm_mem_profile_enabled

Function cbm_mem_profile_enabled

src/foundation/mem_profile.c:80–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78}
79
80bool cbm_mem_profile_enabled(void) {
81 int state = atomic_load_explicit(&g_profile_enabled, memory_order_acquire);
82 if (state >= 0) {
83 return state == 1;
84 }
85 char buf[CBM_SZ_32];
86 bool on = cbm_safe_getenv("CBM_MEM_PROFILE", buf, sizeof(buf), NULL) != NULL && buf[0] == '1';
87 if (on) {
88 char min_buf[CBM_SZ_32];
89 if (cbm_safe_getenv("CBM_MEM_PROFILE_MIN", min_buf, sizeof(min_buf), NULL) != NULL) {
90 long parsed = strtol(min_buf, NULL, 10);
91 if (parsed > 0) {
92 g_profile_min = (size_t)parsed;
93 }
94 }
95 cbm_mutex_init(&g_profile_mutex);
96 }
97 atomic_store_explicit(&g_profile_enabled, on ? 1 : 0, memory_order_release);
98 return on;
99}
100
101/* FNV-1a over the return addresses: cheap, and collisions merely merge two
102 * sites rather than corrupting counts. */

Callers 5

cbm_mem_profile_alloc_atFunction · 0.85
cbm_mem_profile_freeFunction · 0.85
cbm_mem_profile_totalsFunction · 0.85
cbm_mem_profile_dumpFunction · 0.85

Calls 2

cbm_safe_getenvFunction · 0.85
cbm_mutex_initFunction · 0.85

Tested by

no test coverage detected