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

Function read_file_bytes

tests/test_pipeline.c:20438–20463  ·  view source on GitHub ↗

Whole-file read for byte-identity assertions on a published database. */

Source from the content-addressed store, hash-verified

20436
20437/* Whole-file read for byte-identity assertions on a published database. */
20438static unsigned char *read_file_bytes(const char *path, size_t *len_out) {
20439 *len_out = 0;
20440 FILE *f = fopen(path, "rb");
20441 if (!f) {
20442 return NULL;
20443 }
20444 long size = fseek(f, 0, SEEK_END) == 0 ? ftell(f) : -1;
20445 if (size < 0) {
20446 fclose(f);
20447 return NULL;
20448 }
20449 rewind(f);
20450 unsigned char *buf = malloc((size_t)size + 1);
20451 if (!buf) {
20452 fclose(f);
20453 return NULL;
20454 }
20455 size_t got = fread(buf, 1, (size_t)size, f);
20456 fclose(f);
20457 if (got != (size_t)size) {
20458 free(buf);
20459 return NULL;
20460 }
20461 *len_out = got;
20462 return buf;
20463}
20464
20465TEST(pipeline_backpressure_futile_nap_disengages) {
20466 /* 64 tiny files: > MIN_FILES_FOR_PARALLEL (50) so the parallel path (and its

Callers 1

test_pipeline.cFile · 0.85

Calls 2

fopenFunction · 0.85
freadFunction · 0.85

Tested by

no test coverage detected