diff --git a/run_profile.sh b/run_profile.sh index c5c97bb3..cc1528ea 100644 --- a/run_profile.sh +++ b/run_profile.sh @@ -4,7 +4,7 @@ python prebuild.py SRC=$(find src/ -name "*.c") -gcc -pg -Og -std=c11 -Wfatal-errors -o main $SRC src2/main.c -Iinclude +gcc -pg -Og -std=c11 -Wfatal-errors -o main $SRC src2/main.c -Iinclude -lm -DNDEBUG -flto ./main benchmarks/fib.py gprof main gmon.out > gprof.txt rm gmon.out diff --git a/src2/main.c b/src2/main.c index 39d8f381..cad5340a 100644 --- a/src2/main.c +++ b/src2/main.c @@ -10,7 +10,7 @@ #endif char* read_file(const char* path) { - FILE* file = fopen(path, "r"); + FILE* file = fopen(path, "rb"); if(file == NULL) { printf("Error: file not found\n"); return NULL; @@ -19,7 +19,7 @@ char* read_file(const char* path) { long size = ftell(file); fseek(file, 0, SEEK_SET); char* buffer = malloc(size + 1); - fread(buffer, 1, size, file); + size = fread(buffer, 1, size, file); buffer[size] = 0; return buffer; }