From d7894fa7fe098a8c49334c7e2d4af8a70c10f615 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Wed, 12 Mar 2025 22:06:45 -0500 Subject: [PATCH] Bugfix: The macro _f_memory_NO_zeroing_on_larger_ is being applied on smaller. If the new memory size is smalle, then the _f_memory_NO_zeroing_on_larger_ should not be used. --- level_0/f_memory/c/private-memory.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/level_0/f_memory/c/private-memory.c b/level_0/f_memory/c/private-memory.c index af9d33b..a281234 100644 --- a/level_0/f_memory/c/private-memory.c +++ b/level_0/f_memory/c/private-memory.c @@ -14,15 +14,13 @@ extern "C" { } if (*pointer) { - #ifndef _f_memory_NO_zeroing_on_larger_ - if (length_old) { - if (length_new < length_old) { + if (length_old) { + if (length_new < length_old) { - // Casting (void *) to (uint8_t *) should result in an increment of size 1 and avoids problems with (void *) having arithmetic issues. - memset((void *) (((uint8_t *) *pointer) + length_new), 0, type_size * (length_old - length_new)); - } + // Casting (void *) to (uint8_t *) should result in an increment of size 1 and avoids problems with (void *) having arithmetic issues. + memset((void *) (((uint8_t *) *pointer) + length_new), 0, type_size * (length_old - length_new)); } - #endif // _f_memory_NO_zeroing_on_larger_ + } if (length_new) { #ifdef _f_memory_USE_reallocarray_ -- 1.8.3.1