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

Function cbm_max_file_bytes

src/foundation/limits.c:11–28  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9#include <stdlib.h>
10
11long cbm_max_file_bytes(void) {
12 /* 512 MiB — generous: real source files never approach it, but a
13 * pathological / vendored blob degrades to a reported "oversized" skip
14 * instead of a silent drop or an unbounded read. */
15 const long default_cap = 512L * 1024 * 1024;
16
17 const char *raw = cbm_runtime_getenv("CBM_MAX_FILE_BYTES");
18 if (raw && raw[0]) {
19 errno = 0;
20 char *end = NULL;
21 long v = strtol(raw, &end, 10);
22 if (errno == 0 && end != raw && *end == '\0' && v > 0) {
23 return v;
24 }
25 /* Unparseable / non-positive → fall through to the safe default. */
26 }
27 return default_cap;
28}
29
30/* Shared env-int parser: a positive integer in [1, INT_MAX], else the fallback.
31 * Read fresh each call (see cbm_max_file_bytes rationale — cheap, test-friendly,

Callers 15

fl_addFunction · 0.85
doclink_read_fileFunction · 0.85
doclink_scan_repoFunction · 0.85
op_read_fileFunction · 0.85
an_readFunction · 0.85
read_fileFunction · 0.85
k8s_read_fileFunction · 0.85
closure_ansible_declineFunction · 0.85
read_fileFunction · 0.85
extract_workerFunction · 0.85
sh_readFunction · 0.85
read_fileFunction · 0.85

Calls 1

cbm_runtime_getenvFunction · 0.85

Tested by

no test coverage detected