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

Function cbm_mem_phase_mark

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

Source from the content-addressed store, hash-verified

690}
691
692void cbm_mem_phase_mark(const char *label) {
693 if (!mem_phase_enabled()) {
694 return;
695 }
696 size_t now = mem_phase_committed();
697 cbm_mutex_lock(&g_mem_phase_mutex);
698 if (g_mem_phase_open) {
699 int slot = -1;
700 for (int i = 0; i < g_mem_phase_count; i++) {
701 if (g_mem_phases[i].label == g_mem_phase_open ||
702 strcmp(g_mem_phases[i].label, g_mem_phase_open) == 0) {
703 slot = i;
704 break;
705 }
706 }
707 if (slot < 0 && g_mem_phase_count < MEM_PHASE_SLOTS) {
708 slot = g_mem_phase_count++;
709 g_mem_phases[slot].label = g_mem_phase_open;
710 g_mem_phases[slot].bytes = 0;
711 g_mem_phases[slot].hits = 0;
712 }
713 if (slot >= 0) {
714 g_mem_phases[slot].bytes += (int64_t)now - (int64_t)g_mem_phase_baseline;
715 g_mem_phases[slot].hits++;
716 }
717 }
718 g_mem_phase_open = label;
719 g_mem_phase_baseline = now;
720 cbm_mutex_unlock(&g_mem_phase_mutex);
721}
722
723void cbm_mem_phase_reset(void) {
724 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