From 7f104b49d78a199356eafff37ec5786fb3a90e54 Mon Sep 17 00:00:00 2001 From: knot126 <73200930+knot126@users.noreply.github.com> Date: Thu, 13 Jun 2024 03:55:16 +0000 Subject: [PATCH] Hide old alloc functions behind macro --- source/memory.c | 8 +++++--- source/memory.h | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/source/memory.c b/source/memory.c index edc1cb3..694672d 100644 --- a/source/memory.c +++ b/source/memory.c @@ -21,6 +21,7 @@ #include "memory.h" +#if DG_MELON_OLD_MEMORY_FUNCTIONS void *DgAlloc(size_t size) { /** * Allocate some memory, or return NULL on failure. @@ -53,6 +54,7 @@ void *DgRealloc(void* block, size_t size) { return realloc(block, size); } +#endif void *DgMemoryAllocate(size_t size) { /** @@ -62,7 +64,7 @@ void *DgMemoryAllocate(size_t size) { * @return Pointer to the allocated memory, or NULL if failed */ - return DgAlloc(size); + return malloc(size); } DgError DgMemoryFree(void *block) { @@ -78,7 +80,7 @@ DgError DgMemoryFree(void *block) { return DG_ERROR_NOT_SAFE; } - DgFree(block); + free(block); return DG_ERROR_SUCCESS; } @@ -104,7 +106,7 @@ void *DgMemoryReallocate(void* block, size_t size) { return DgMemoryAllocate(size); } else { - return DgRealloc(block, size); + return realloc(block, size); } } diff --git a/source/memory.h b/source/memory.h index 3304fdf..a3de29e 100644 --- a/source/memory.h +++ b/source/memory.h @@ -17,9 +17,11 @@ #include #include "error.h" +#if DG_MELON_OLD_MEMORY_FUNCTIONS void *DgAlloc(size_t size); void DgFree(void *block); void *DgRealloc(void *block, size_t size); +#endif void *DgMemoryAllocate(size_t size); DgError DgMemoryFree(void *block);