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

Function cbm_mem_phase_mark

src/foundation/mem.c:962–992  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

960}
961
962void cbm_mem_phase_mark(const char *label) {
963 cbm_memev_phase(label); /* waste sanitizer: dormant unless CBM_MEMWASTE=1 */
964 if (!mem_phase_enabled()) {
965 return;
966 }
967 size_t now = mem_phase_committed();
968 cbm_mutex_lock(&g_mem_phase_mutex);
969 if (g_mem_phase_open) {
970 int slot = -1;
971 for (int i = 0; i < g_mem_phase_count; i++) {
972 if (g_mem_phases[i].label == g_mem_phase_open ||
973 strcmp(g_mem_phases[i].label, g_mem_phase_open) == 0) {
974 slot = i;
975 break;
976 }
977 }
978 if (slot < 0 && g_mem_phase_count < MEM_PHASE_SLOTS) {
979 slot = g_mem_phase_count++;
980 g_mem_phases[slot].label = g_mem_phase_open;
981 g_mem_phases[slot].bytes = 0;
982 g_mem_phases[slot].hits = 0;
983 }
984 if (slot >= 0) {
985 g_mem_phases[slot].bytes += (int64_t)now - (int64_t)g_mem_phase_baseline;
986 g_mem_phases[slot].hits++;
987 }
988 }
989 g_mem_phase_open = label;
990 g_mem_phase_baseline = now;
991 cbm_mutex_unlock(&g_mem_phase_mutex);
992}
993
994void cbm_mem_phase_reset(void) {
995 if (!mem_phase_enabled()) {

Callers 4

handle_search_graphFunction · 0.85
cbm_mcp_handle_toolFunction · 0.85
pipeline_phase_markFunction · 0.85
cbm_pipeline_runFunction · 0.85

Calls 5

cbm_memev_phaseFunction · 0.85
mem_phase_enabledFunction · 0.85
mem_phase_committedFunction · 0.85
cbm_mutex_lockFunction · 0.85
cbm_mutex_unlockFunction · 0.85

Tested by

no test coverage detected