diff options
Diffstat (limited to 'src/util')
| -rw-r--r-- | src/util/file/util.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/util/file/util.c b/src/util/file/util.c index a2201a7..2f1fa36 100644 --- a/src/util/file/util.c +++ b/src/util/file/util.c @@ -15,12 +15,13 @@ s32 nn_file_read_as_str(struct nn_file *file, str *out) s32 nn_file_read_as_c_str(struct nn_file *file, char **out) { size_t size = file->size; - *out = (char *)al_malloc(size + 1); - if (!nn_file_read(file, (void *)*out, size)) { + char *c_str = (char *)al_malloc(size + 1); + if (!nn_file_read(file, c_str, size)) { al_free(*out); return -1; } - (*out)[size] = '\n'; + c_str[size] = '\n'; + *out = c_str; return size; } |