diff options
author | dec05eba <dec05eba@protonmail.com> | 2019-02-24 02:10:58 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-25 14:36:40 +0200 |
commit | 11dc4b81935e3dfee997c421d8d6fa166edd7a05 (patch) | |
tree | ccb08be54209a4900c740c9ed58e8f9c2910811d /src/alloc.c |
Initial commit, Function declaration work somewhat
Diffstat (limited to 'src/alloc.c')
-rw-r--r-- | src/alloc.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/alloc.c b/src/alloc.c new file mode 100644 index 0000000..c9ca7c3 --- /dev/null +++ b/src/alloc.c @@ -0,0 +1,25 @@ +#include "../include/alloc.h" +#include <stdlib.h> + +int am_malloc(usize size, void **mem) { + void *allocated_data = malloc(size); + if(!allocated_data) + return ALLOC_FAIL; + + *mem = allocated_data; + return ALLOC_OK; +} + +int am_realloc(void *mem, usize new_size, void **new_mem) { + void *new_allocated_data = realloc(mem, new_size); + if(!new_allocated_data) + return ALLOC_FAIL; + + *new_mem = new_allocated_data; + return ALLOC_OK; +} + +void am_free(void *mem) { + free(mem); +} + |