From bb64c8c1925771aeee64e4768e1d369860d51d6a Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Mon, 11 Mar 2024 00:12:29 -0500 Subject: [PATCH] Cleaup: Inline comment regarding cast to uint8_t in f_memory functions. --- level_0/f_memory/c/memory.c | 3 +-- level_0/f_memory/c/private-memory.c | 9 +++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/level_0/f_memory/c/memory.c b/level_0/f_memory/c/memory.c index eb228f4..b4881ff 100644 --- a/level_0/f_memory/c/memory.c +++ b/level_0/f_memory/c/memory.c @@ -132,8 +132,7 @@ extern "C" { } #endif // _f_memory_USE_posix_memalign_ - // uint8_t * is of a data size of 1, casting it to uint8_t should result in a single-length increment. - // This is done to avoid problems with (void *) having arithmetic issues. + // Casting (void *) to (uint8_t *) should result in an increment of size 1 and avoids problems with (void *) having arithmetic issues. memset(((uint8_t *) *pointer), 0, length); return F_none; diff --git a/level_0/f_memory/c/private-memory.c b/level_0/f_memory/c/private-memory.c index 8c32340..28a7538 100644 --- a/level_0/f_memory/c/private-memory.c +++ b/level_0/f_memory/c/private-memory.c @@ -16,8 +16,7 @@ extern "C" { if (length_old) { if (length_new < length_old) { - // uint8_t * is of a data size size of 1, casting it to uint8_t should result in a single-length increment. - // This is done to avoid problems with (void *) having arithmetic issues. + // Casting (void *) to (uint8_t *) should result in an increment of size 1 and avoids problems with (void *) having arithmetic issues. memset(((uint8_t *) *pointer) + length_new, 0, type_size * (length_old - length_new)); } } @@ -28,8 +27,7 @@ extern "C" { if (new_pointer) { if (length_new > length_old) { - // uint8_t * is of a data size size of 1, casting it to bool should result in a single-length increment. - // This is done to avoid problems with (void *) having arithmetic issues. + // Casting (void *) to (uint8_t *) should result in an increment of size 1 and avoids problems with (void *) having arithmetic issues. memset(((uint8_t *) new_pointer) + (type_size * length_old), 0, type_size * (length_new - length_old)); } @@ -76,8 +74,7 @@ extern "C" { if (new_pointer) { if (length_new > length_old) { - // uint8_t * is of a data size size of 1, casting it to bool should result in a single-length increment. - // This is done to avoid problems with (void *) having arithmetic issues. + // Casting (void *) to (uint8_t *) should result in an increment of size 1 and avoids problems with (void *) having arithmetic issues. memset(((uint8_t *) new_pointer) + (type_size * length_old), 0, type_size * (length_new - length_old)); } -- 1.8.3.1