diff options
author | dec05eba <dec05eba@protonmail.com> | 2019-03-18 23:47:45 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-25 14:36:46 +0200 |
commit | 2323ca6c9ec3c8ee76b9acf13745b80b92952a6a (patch) | |
tree | 93013237dbcb0fa96ceb5f3c026fd040aff464cf /src/std/alloc.c | |
parent | 5a93c32a59775cd1be4b4f450e8230016b434366 (diff) |
Add struct, import caching, binop ops etc
Diffstat (limited to 'src/std/alloc.c')
-rw-r--r-- | src/std/alloc.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/std/alloc.c b/src/std/alloc.c index 93dcb98..d07e94f 100644 --- a/src/std/alloc.c +++ b/src/std/alloc.c @@ -1,10 +1,13 @@ #include "../../include/std/alloc.h" +#include "../../include/std/log.h" #include <stdlib.h> int am_malloc(usize size, void **mem) { void *allocated_data = malloc(size); - if(!allocated_data) + if(!allocated_data) { + amal_log_error("am_malloc: failed to allocate memory of size %lu", size); return ALLOC_FAIL; + } *mem = allocated_data; return ALLOC_OK; @@ -12,8 +15,10 @@ int am_malloc(usize size, void **mem) { int am_realloc(void *mem, usize new_size, void **new_mem) { void *new_allocated_data = realloc(mem, new_size); - if(!new_allocated_data) + if(!new_allocated_data) { + amal_log_error("am_malloc: failed to reallocate memory to size %lu", new_size); return ALLOC_FAIL; + } *new_mem = new_allocated_data; return ALLOC_OK; |