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

Function gd_bytes

src/store/store_graph_digest.c:280–306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

278}
279
280static bool gd_bytes(gd_context_t *g, const void *data, size_t length) {
281 if (!gd_check(g)) {
282 return false;
283 }
284 uint64_t count = (uint64_t)length;
285 if ((size_t)count != length || count > g->limits.max_framed_bytes - g->bytes) {
286 return gd_fail(g, CBM_STORE_GRAPH_DIGEST_LIMIT);
287 }
288 if (length && !data) {
289 return gd_fail(g, CBM_STORE_GRAPH_DIGEST_ERROR);
290 }
291 const unsigned char *p = data;
292 while (length) {
293 size_t chunk = length > GD_CHUNK_BYTES ? GD_CHUNK_BYTES : length;
294 if (!gd_check(g)) {
295 return false;
296 }
297 cbm_sha256_update(&g->sha, p, chunk);
298 g->bytes += (uint64_t)chunk;
299 if (!gd_check(g)) {
300 return false;
301 }
302 p += chunk;
303 length -= chunk;
304 }
305 return true;
306}
307
308static bool gd_u8(gd_context_t *g, unsigned char value) {
309 return gd_bytes(g, &value, 1);

Callers 5

gd_u8Function · 0.85
gd_u32Function · 0.85
gd_u64Function · 0.85
gd_valueFunction · 0.85
cbm_store_graph_digestFunction · 0.85

Calls 3

gd_checkFunction · 0.85
gd_failFunction · 0.85
cbm_sha256_updateFunction · 0.85

Tested by

no test coverage detected