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

Function cbm_retain_env_bytes

src/pipeline/pass_parallel.c:145–157  ·  view source on GitHub ↗

Parse a positive MB-valued retention env knob (CBM_RETAIN_*_MB) into bytes. * Follows the limits.c strtol convention: unset / unparseable / non-positive * → return 0 so the caller keeps its derived default. */

Source from the content-addressed store, hash-verified

143 * Follows the limits.c strtol convention: unset / unparseable / non-positive
144 * → return 0 so the caller keeps its derived default. */
145static size_t cbm_retain_env_bytes(const char *name) {
146 const char *raw = cbm_runtime_getenv(name);
147 if (!raw || !raw[0]) {
148 return 0;
149 }
150 errno = 0;
151 char *end = NULL;
152 long v = strtol(raw, &end, 10);
153 if (errno != 0 || end == raw || *end != '\0' || v <= 0) {
154 return 0;
155 }
156 return (size_t)v * 1024 * 1024;
157}
158
159/* Auto-derived TOTAL retention budget: a fraction of the process memory
160 * budget, clamped to the absolute ceiling. The clamp bounds ONLY this

Callers 1

Calls 1

cbm_runtime_getenvFunction · 0.85

Tested by

no test coverage detected