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

Function jl_read

tests/test_config_json_like.c:88–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

jl_failed_unchangedFunction · 0.85

Calls 1

cbm_fopenFunction · 0.85

Tested by

no test coverage detected