aboutsummaryrefslogtreecommitdiffstats
path: root/src/bootstrap/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bootstrap/main.c')
-rwxr-xr-xsrc/bootstrap/main.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/bootstrap/main.c b/src/bootstrap/main.c
index c2c88d6..73a9244 100755
--- a/src/bootstrap/main.c
+++ b/src/bootstrap/main.c
@@ -207,16 +207,12 @@ run_file(char *file_name) {
207void 207void
208run_stdin(void) { 208run_stdin(void) {
209 size_t buf_size = 0; 209 size_t buf_size = 0;
210 size_t buf_cap = STDIN_BUF_CAP; 210 char *source = NULL;
211 char *source = malloc(buf_cap * sizeof(char)); 211 array_init(source, STDIN_BUF_CAP);
212 212
213 char c; 213 char c;
214 while ((c = getchar()) != EOF) { 214 while ((c = getchar()) != EOF) {
215 if (buf_size == buf_cap) { 215 array_push(source, c);
216 buf_cap *= 2;
217 source = realloc(source, buf_cap * sizeof(char));
218 }
219 source[buf_size] = c;
220 buf_size++; 216 buf_size++;
221 } 217 }
222 218
@@ -240,7 +236,7 @@ run_stdin(void) {
240 errors_n = 0; 236 errors_n = 0;
241 } 237 }
242 238
243 free(source); 239 array_free(source);
244} 240}
245 241
246#ifndef BIN_NAME 242#ifndef BIN_NAME