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

Function jl_read

tests/test_config_json_like.c:90–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88}
89
90static char *jl_read(const char *path) {
91 FILE *file = cbm_fopen(path, "rb");
92 if (!file || fseek(file, 0, SEEK_END) != 0) {
93 if (file) {
94 fclose(file);
95 }
96 return NULL;
97 }
98 long size = ftell(file);
99 if (size < 0 || fseek(file, 0, SEEK_SET) != 0) {
100 fclose(file);
101 return NULL;
102 }
103 char *content = malloc((size_t)size + 1U);
104 if (!content) {
105 fclose(file);
106 return NULL;
107 }
108 size_t read_count = fread(content, 1U, (size_t)size, file);
109 int failed = ferror(file);
110 fclose(file);
111 if (read_count != (size_t)size || failed) {
112 free(content);
113 return NULL;
114 }
115 content[read_count] = '\0';
116 return content;
117}
118
119static int jl_failed_unchanged(const char *path, const char *original,
120 const char *const *object_path, size_t path_len, const char *key,

Callers 3

jl_failed_unchangedFunction · 0.85
jl_round_tripsFunction · 0.85

Calls 1

cbm_fopenFunction · 0.85

Tested by

no test coverage detected