diff options
author | A404M <ahmadmahmoudiprogrammer@gmail.com> | 2025-01-18 20:42:54 +0330 |
---|---|---|
committer | A404M <ahmadmahmoudiprogrammer@gmail.com> | 2025-01-18 20:49:30 +0330 |
commit | 43392fc66ab207e53a6924a2edbcd7ca0acecea8 (patch) | |
tree | 5a064c4e144035d1a07f31f767417b9e44b2ebbf /src/utils/memory.c |
initial commit
Diffstat (limited to 'src/utils/memory.c')
-rw-r--r-- | src/utils/memory.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/utils/memory.c b/src/utils/memory.c new file mode 100644 index 0000000..cde2995 --- /dev/null +++ b/src/utils/memory.c @@ -0,0 +1,31 @@ +#include "memory.h" + +#include <stdlib.h> +#include <malloc.h> + +void *a404m_malloc(size_t size) { + if (size == 0) { + return NULL; + } else { + return malloc(size); + } +} + +void *a404m_realloc(void *restrict pointer, size_t size) { + if (size == 0) { + free(pointer); + return NULL; + } else if (pointer != NULL) { + return realloc(pointer, size); + } else { + return malloc(size); + } +} + +size_t a404m_malloc_usable_size(void *pointer) { + if (pointer == NULL) { + return 0; + } else { + return malloc_usable_size(pointer); + } +} |