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

Function cbm_vmem_init

src/foundation/vmem.c:109–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107/* ── Public API ────────────────────────────────────────────────── */
108
109void cbm_vmem_init(double ram_fraction) {
110 /* Only first call takes effect */
111 int expected = 0;
112 if (!atomic_compare_exchange_strong(&g_initialized, &expected, 1)) {
113 return;
114 }
115
116 if (ram_fraction <= 0.0 || ram_fraction > 1.0) {
117 ram_fraction = 0.5;
118 }
119
120 cbm_system_info_t info = cbm_system_info();
121 g_budget = (size_t)((double)info.total_ram * ram_fraction);
122
123 char budget_mb[CBM_SZ_32];
124 char ram_mb[CBM_SZ_32];
125 snprintf(budget_mb, sizeof(budget_mb), "%zu", g_budget / MB_DIVISOR);
126 snprintf(ram_mb, sizeof(ram_mb), "%zu", info.total_ram / MB_DIVISOR);
127 cbm_log_info("vmem.init", "budget_mb", budget_mb, "total_ram_mb", ram_mb);
128}
129
130void *cbm_vmem_alloc(size_t size) {
131 if (size == 0) {

Callers 1

test_vmem.cFile · 0.85

Calls 1

cbm_system_infoFunction · 0.85

Tested by

no test coverage detected