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

Function cbm_getline

src/foundation/compat.c:131–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129
130#ifdef _WIN32
131ssize_t cbm_getline(char **lineptr, size_t *n, FILE *stream) {
132 if (!lineptr || !n || !stream) {
133 return CBM_NOT_FOUND;
134 }
135 if (!*lineptr || *n == 0) {
136 *n = CBM_SZ_128;
137 *lineptr = (char *)malloc(*n);
138 if (!*lineptr) {
139 return CBM_NOT_FOUND;
140 }
141 }
142 size_t pos = 0;
143 int c;
144 while ((c = fgetc(stream)) != EOF) {
145 if (pos + 1 >= *n) {
146 size_t new_n = *n * PAIR_LEN;
147 char *tmp = (char *)realloc(*lineptr, new_n);
148 if (!tmp) {
149 return CBM_NOT_FOUND;
150 }
151 *lineptr = tmp;
152 *n = new_n;
153 }
154 (*lineptr)[pos++] = (char)c;
155 if (c == '\n') {
156 break;
157 }
158 }
159 if (pos == 0 && c == EOF) {
160 return CBM_NOT_FOUND;
161 }
162 (*lineptr)[pos] = '\0';
163 return (ssize_t)pos;
164}
165#endif

Callers 2

cbm_mcp_server_runFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected