diff options
author | A404M <ahmadmahmoudiprogrammer@gmail.com> | 2024-09-25 19:47:29 +0330 |
---|---|---|
committer | A404M <ahmadmahmoudiprogrammer@gmail.com> | 2024-09-25 19:47:29 +0330 |
commit | c409b8aaf6b6f63bd68a3356e146ab80b2ec8c4b (patch) | |
tree | 65ea5801fd910fc6bcff3f2e8f06b5fd7d249c78 /src/utils/memory | |
parent | f79290084948f3cf140395c270c07cf29ca58e8d (diff) |
fixed multiple variable definition bug
tried to implement import
Diffstat (limited to 'src/utils/memory')
-rw-r--r-- | src/utils/memory/memory.c | 13 | ||||
-rw-r--r-- | src/utils/memory/memory.h | 3 |
2 files changed, 13 insertions, 3 deletions
diff --git a/src/utils/memory/memory.c b/src/utils/memory/memory.c index d793bc7..cde2995 100644 --- a/src/utils/memory/memory.c +++ b/src/utils/memory/memory.c @@ -1,6 +1,7 @@ #include "memory.h" #include <stdlib.h> +#include <malloc.h> void *a404m_malloc(size_t size) { if (size == 0) { @@ -14,9 +15,17 @@ void *a404m_realloc(void *restrict pointer, size_t size) { if (size == 0) { free(pointer); return NULL; - } else if(pointer != NULL) { + } else if (pointer != NULL) { return realloc(pointer, size); - }else{ + } else { return malloc(size); } } + +size_t a404m_malloc_usable_size(void *pointer) { + if (pointer == NULL) { + return 0; + } else { + return malloc_usable_size(pointer); + } +} diff --git a/src/utils/memory/memory.h b/src/utils/memory/memory.h index 1c5017f..29bd3db 100644 --- a/src/utils/memory/memory.h +++ b/src/utils/memory/memory.h @@ -3,4 +3,5 @@ #include <stddef.h> extern void *a404m_malloc(size_t size); -extern void *a404m_realloc(void *restrict pointer,size_t size); +extern void *a404m_realloc(void *restrict pointer, size_t size); +extern size_t a404m_malloc_usable_size(void *pointer); |