MCPcopy Create free account
hub / github.com/IBM/Project_CodeNet / read_input

Function read_input

tools/json-graph/src/jgflib.c:190–211  ·  view source on GitHub ↗

Get input file as one long string in global input. Returns number of bytes read. */

Source from the content-addressed store, hash-verified

188 Returns number of bytes read.
189*/
190static size_t read_input(void)
191{
192 size_t nread = 0;
193 size_t nalloc = 1024;
194 input = malloc(nalloc);
195 char *p = (char *)input;
196 int cc;
197
198 while ((cc = getchar()) != EOF) {
199 if (nread == nalloc) {
200 nalloc <<= 1;
201 input = realloc((void *)input, nalloc);
202 /* reset p to correct spot in input: */
203 p = (char *)input+nread;
204 }
205 *p++ = cc;
206 nread++;
207 }
208 /* No need for terminating \0 char. */
209 if (debug) fprintf(stderr, "(D): Read %u bytes.\n", nread);
210 return nread;
211}
212
213/** Parse the JSON input (global) into an array of tokens.
214 Returns the allocated token array.

Callers 1

parseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected