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

Function cbm_mem_phase_mark

src/foundation/mem.c:721–750  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

719}
720
721void cbm_mem_phase_mark(const char *label) {
722 if (!mem_phase_enabled()) {
723 return;
724 }
725 size_t now = mem_phase_committed();
726 cbm_mutex_lock(&g_mem_phase_mutex);
727 if (g_mem_phase_open) {
728 int slot = -1;
729 for (int i = 0; i < g_mem_phase_count; i++) {
730 if (g_mem_phases[i].label == g_mem_phase_open ||
731 strcmp(g_mem_phases[i].label, g_mem_phase_open) == 0) {
732 slot = i;
733 break;
734 }
735 }
736 if (slot < 0 && g_mem_phase_count < MEM_PHASE_SLOTS) {
737 slot = g_mem_phase_count++;
738 g_mem_phases[slot].label = g_mem_phase_open;
739 g_mem_phases[slot].bytes = 0;
740 g_mem_phases[slot].hits = 0;
741 }
742 if (slot >= 0) {
743 g_mem_phases[slot].bytes += (int64_t)now - (int64_t)g_mem_phase_baseline;
744 g_mem_phases[slot].hits++;
745 }
746 }
747 g_mem_phase_open = label;
748 g_mem_phase_baseline = now;
749 cbm_mutex_unlock(&g_mem_phase_mutex);
750}
751
752void cbm_mem_phase_reset(void) {
753 if (!mem_phase_enabled()) {

Callers 2

handle_search_graphFunction · 0.85
cbm_mcp_handle_toolFunction · 0.85

Calls 4

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