aboutsummaryrefslogtreecommitdiff
path: root/src/parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser.c')
-rw-r--r--src/parser.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/parser.c b/src/parser.c
index da85292..bb7c8d3 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -5,6 +5,7 @@
#include "../include/std/file.h"
#include "../include/std/mem.h"
#include "../include/std/log.h"
+#include "../include/std/alloc.h"
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
@@ -220,8 +221,8 @@ int parser_parse_buffer(Parser *self, BufferView code_buffer, BufferView buffer_
int parser_parse_file(Parser *self, BufferView filepath) {
int result;
- int mapped_file_deinit_result;
- MappedFile mapped_file;
+ char *file_data;
+ usize file_size;
char *filepath_tmp;
amal_log_debug("Parsing %.*s", (int)filepath.size, filepath.data);
@@ -232,11 +233,12 @@ int parser_parse_file(Parser *self, BufferView filepath) {
filepath_tmp = malloc(filepath.size + 1);
am_memcpy(filepath_tmp, filepath.data, filepath.size);
filepath_tmp[filepath.size] = '\0';
- result = mapped_file_init(&mapped_file, filepath_tmp, MAPPED_FILE_READ);
+ result = read_whole_file(filepath_tmp, &file_data, &file_size);
if(result != 0) return result;
- result = parser_parse_buffer(self, create_buffer_view(mapped_file.file_data, mapped_file.file_size), filepath);
- mapped_file_deinit_result = mapped_file_deinit(&mapped_file);
- return result != 0 ? result : mapped_file_deinit_result;
+ result = parser_parse_buffer(self, create_buffer_view(file_data, file_size), create_buffer_view(filepath_tmp, filepath.size));
+ /* TODO: Somehow free this.. causes issue where filepath becomes corrupt */
+ /*am_free(file_data);*/
+ return result;
}
/*