Read the file into a dynamic array to avoid stack overflow
This commit is contained in:
parent
dde80250ed
commit
f1519cf0ea
@ -16,9 +16,9 @@
|
||||
"main",
|
||||
"src/main.c"
|
||||
],
|
||||
"directory": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json",
|
||||
"file": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json/src/main.c",
|
||||
"output": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json/main"
|
||||
"directory": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say-it-in-json",
|
||||
"file": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say-it-in-json/src/main.c",
|
||||
"output": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say-it-in-json/main"
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
@ -37,9 +37,9 @@
|
||||
"main",
|
||||
"src/dstring/dstring.c"
|
||||
],
|
||||
"directory": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json",
|
||||
"file": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json/src/dstring/dstring.c",
|
||||
"output": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json/main"
|
||||
"directory": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say-it-in-json",
|
||||
"file": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say-it-in-json/src/dstring/dstring.c",
|
||||
"output": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say-it-in-json/main"
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
@ -58,9 +58,9 @@
|
||||
"main",
|
||||
"src/json_entities/json_entities.c"
|
||||
],
|
||||
"directory": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json",
|
||||
"file": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json/src/json_entities/json_entities.c",
|
||||
"output": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json/main"
|
||||
"directory": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say-it-in-json",
|
||||
"file": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say-it-in-json/src/json_entities/json_entities.c",
|
||||
"output": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say-it-in-json/main"
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
@ -79,9 +79,9 @@
|
||||
"main",
|
||||
"src/lexer/lexer.c"
|
||||
],
|
||||
"directory": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json",
|
||||
"file": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json/src/lexer/lexer.c",
|
||||
"output": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json/main"
|
||||
"directory": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say-it-in-json",
|
||||
"file": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say-it-in-json/src/lexer/lexer.c",
|
||||
"output": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say-it-in-json/main"
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
@ -100,9 +100,9 @@
|
||||
"main",
|
||||
"src/parser/parser.c"
|
||||
],
|
||||
"directory": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json",
|
||||
"file": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json/src/parser/parser.c",
|
||||
"output": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json/main"
|
||||
"directory": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say-it-in-json",
|
||||
"file": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say-it-in-json/src/parser/parser.c",
|
||||
"output": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say-it-in-json/main"
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
@ -134,7 +134,7 @@
|
||||
"-debug-info-kind=constructor",
|
||||
"-dwarf-version=4",
|
||||
"-debugger-tuning=gdb",
|
||||
"-fcoverage-compilation-dir=/home/abdelrahman/dev_work/say_it_in_json",
|
||||
"-fcoverage-compilation-dir=/home/abdelrahman/dev_work/say-it-in-json",
|
||||
"-resource-dir",
|
||||
"/usr/lib64/clang/16",
|
||||
"-I",
|
||||
@ -160,7 +160,7 @@
|
||||
"-Wall",
|
||||
"-Werror",
|
||||
"-pedantic",
|
||||
"-fdebug-compilation-dir=/home/abdelrahman/dev_work/say_it_in_json",
|
||||
"-fdebug-compilation-dir=/home/abdelrahman/dev_work/say-it-in-json",
|
||||
"-ferror-limit",
|
||||
"19",
|
||||
"-fgnuc-version=4.2.1",
|
||||
@ -170,12 +170,12 @@
|
||||
"-x",
|
||||
"c",
|
||||
"-o",
|
||||
"/tmp/main-4e7ed0.o",
|
||||
"/tmp/main-dee7e4.o",
|
||||
"src/main.c"
|
||||
],
|
||||
"directory": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json",
|
||||
"file": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json/src/main.c",
|
||||
"output": "/tmp/main-4e7ed0.o"
|
||||
"directory": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say-it-in-json",
|
||||
"file": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say-it-in-json/src/main.c",
|
||||
"output": "/tmp/main-dee7e4.o"
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
@ -207,7 +207,7 @@
|
||||
"-debug-info-kind=constructor",
|
||||
"-dwarf-version=4",
|
||||
"-debugger-tuning=gdb",
|
||||
"-fcoverage-compilation-dir=/home/abdelrahman/dev_work/say_it_in_json",
|
||||
"-fcoverage-compilation-dir=/home/abdelrahman/dev_work/say-it-in-json",
|
||||
"-resource-dir",
|
||||
"/usr/lib64/clang/16",
|
||||
"-I",
|
||||
@ -233,7 +233,7 @@
|
||||
"-Wall",
|
||||
"-Werror",
|
||||
"-pedantic",
|
||||
"-fdebug-compilation-dir=/home/abdelrahman/dev_work/say_it_in_json",
|
||||
"-fdebug-compilation-dir=/home/abdelrahman/dev_work/say-it-in-json",
|
||||
"-ferror-limit",
|
||||
"19",
|
||||
"-fgnuc-version=4.2.1",
|
||||
@ -243,12 +243,12 @@
|
||||
"-x",
|
||||
"c",
|
||||
"-o",
|
||||
"/tmp/dstring-762950.o",
|
||||
"/tmp/dstring-ccdbcc.o",
|
||||
"src/dstring/dstring.c"
|
||||
],
|
||||
"directory": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json",
|
||||
"file": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json/src/dstring/dstring.c",
|
||||
"output": "/tmp/dstring-762950.o"
|
||||
"directory": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say-it-in-json",
|
||||
"file": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say-it-in-json/src/dstring/dstring.c",
|
||||
"output": "/tmp/dstring-ccdbcc.o"
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
@ -280,7 +280,7 @@
|
||||
"-debug-info-kind=constructor",
|
||||
"-dwarf-version=4",
|
||||
"-debugger-tuning=gdb",
|
||||
"-fcoverage-compilation-dir=/home/abdelrahman/dev_work/say_it_in_json",
|
||||
"-fcoverage-compilation-dir=/home/abdelrahman/dev_work/say-it-in-json",
|
||||
"-resource-dir",
|
||||
"/usr/lib64/clang/16",
|
||||
"-I",
|
||||
@ -306,7 +306,7 @@
|
||||
"-Wall",
|
||||
"-Werror",
|
||||
"-pedantic",
|
||||
"-fdebug-compilation-dir=/home/abdelrahman/dev_work/say_it_in_json",
|
||||
"-fdebug-compilation-dir=/home/abdelrahman/dev_work/say-it-in-json",
|
||||
"-ferror-limit",
|
||||
"19",
|
||||
"-fgnuc-version=4.2.1",
|
||||
@ -316,12 +316,12 @@
|
||||
"-x",
|
||||
"c",
|
||||
"-o",
|
||||
"/tmp/json_entities-5ce443.o",
|
||||
"/tmp/json_entities-28bb74.o",
|
||||
"src/json_entities/json_entities.c"
|
||||
],
|
||||
"directory": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json",
|
||||
"file": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json/src/json_entities/json_entities.c",
|
||||
"output": "/tmp/json_entities-5ce443.o"
|
||||
"directory": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say-it-in-json",
|
||||
"file": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say-it-in-json/src/json_entities/json_entities.c",
|
||||
"output": "/tmp/json_entities-28bb74.o"
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
@ -353,7 +353,7 @@
|
||||
"-debug-info-kind=constructor",
|
||||
"-dwarf-version=4",
|
||||
"-debugger-tuning=gdb",
|
||||
"-fcoverage-compilation-dir=/home/abdelrahman/dev_work/say_it_in_json",
|
||||
"-fcoverage-compilation-dir=/home/abdelrahman/dev_work/say-it-in-json",
|
||||
"-resource-dir",
|
||||
"/usr/lib64/clang/16",
|
||||
"-I",
|
||||
@ -379,7 +379,7 @@
|
||||
"-Wall",
|
||||
"-Werror",
|
||||
"-pedantic",
|
||||
"-fdebug-compilation-dir=/home/abdelrahman/dev_work/say_it_in_json",
|
||||
"-fdebug-compilation-dir=/home/abdelrahman/dev_work/say-it-in-json",
|
||||
"-ferror-limit",
|
||||
"19",
|
||||
"-fgnuc-version=4.2.1",
|
||||
@ -389,12 +389,12 @@
|
||||
"-x",
|
||||
"c",
|
||||
"-o",
|
||||
"/tmp/lexer-6ba5bd.o",
|
||||
"/tmp/lexer-62ea0a.o",
|
||||
"src/lexer/lexer.c"
|
||||
],
|
||||
"directory": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json",
|
||||
"file": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json/src/lexer/lexer.c",
|
||||
"output": "/tmp/lexer-6ba5bd.o"
|
||||
"directory": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say-it-in-json",
|
||||
"file": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say-it-in-json/src/lexer/lexer.c",
|
||||
"output": "/tmp/lexer-62ea0a.o"
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
@ -426,7 +426,7 @@
|
||||
"-debug-info-kind=constructor",
|
||||
"-dwarf-version=4",
|
||||
"-debugger-tuning=gdb",
|
||||
"-fcoverage-compilation-dir=/home/abdelrahman/dev_work/say_it_in_json",
|
||||
"-fcoverage-compilation-dir=/home/abdelrahman/dev_work/say-it-in-json",
|
||||
"-resource-dir",
|
||||
"/usr/lib64/clang/16",
|
||||
"-I",
|
||||
@ -452,7 +452,7 @@
|
||||
"-Wall",
|
||||
"-Werror",
|
||||
"-pedantic",
|
||||
"-fdebug-compilation-dir=/home/abdelrahman/dev_work/say_it_in_json",
|
||||
"-fdebug-compilation-dir=/home/abdelrahman/dev_work/say-it-in-json",
|
||||
"-ferror-limit",
|
||||
"19",
|
||||
"-fgnuc-version=4.2.1",
|
||||
@ -462,11 +462,11 @@
|
||||
"-x",
|
||||
"c",
|
||||
"-o",
|
||||
"/tmp/parser-95ad8d.o",
|
||||
"/tmp/parser-6ae76d.o",
|
||||
"src/parser/parser.c"
|
||||
],
|
||||
"directory": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json",
|
||||
"file": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say_it_in_json/src/parser/parser.c",
|
||||
"output": "/tmp/parser-95ad8d.o"
|
||||
"directory": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say-it-in-json",
|
||||
"file": "/mnt/3A5CDF785CDF2CFF/Users/abdoo/dev/say-it-in-json/src/parser/parser.c",
|
||||
"output": "/tmp/parser-6ae76d.o"
|
||||
}
|
||||
]
|
||||
|
@ -33,7 +33,7 @@ jentity_t *load_json(const char *filepath) {
|
||||
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
|
||||
char json[length + 1];
|
||||
char *json = (char *)malloc(sizeof(char) * (length + 1));
|
||||
memset(json, 0, length + 1);
|
||||
|
||||
fread(json, sizeof(char), length, fp);
|
||||
@ -76,6 +76,7 @@ jentity_t *load_json(const char *filepath) {
|
||||
|
||||
parser_free(&parser);
|
||||
lexer_free(&lexer);
|
||||
free(json);
|
||||
|
||||
return root;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user