From: Kevin Day Date: Mon, 11 Mar 2024 05:12:42 +0000 (-0500) Subject: Cleaup: Inline comment regarding cast to uint8_t in f_memory functions. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=cc451b8f8746208704ce6200e35a26a51c92d6e4;p=fll Cleaup: Inline comment regarding cast to uint8_t in f_memory functions. --- diff --git a/level_0/f_memory/c/memory/array.c b/level_0/f_memory/c/memory/array.c index ad1b561..3622718 100644 --- a/level_0/f_memory/c/memory/array.c +++ b/level_0/f_memory/c/memory/array.c @@ -43,8 +43,7 @@ extern "C" { } } - // 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. memcpy((void *) (((uint8_t *) (*array)) + (*used * width)), source, width); ++(*used); @@ -77,8 +76,7 @@ extern "C" { } } - // 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. memcpy((void *) (((uint8_t *) (*array)) + (*used * width)), sources, width * amount); *used += amount; diff --git a/level_0/f_memory/c/private-memory.c b/level_0/f_memory/c/private-memory.c index 0afbd43..af9d33b 100644 --- a/level_0/f_memory/c/private-memory.c +++ b/level_0/f_memory/c/private-memory.c @@ -18,8 +18,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((void *) (((uint8_t *) *pointer) + length_new), 0, type_size * (length_old - length_new)); } } @@ -36,8 +35,6 @@ extern "C" { #ifndef _f_memory_NO_zeroing_on_larger_ 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. memset((void *) (((uint8_t *) new_pointer) + (type_size * length_old)), 0, type_size * (length_new - length_old)); } #endif // _f_memory_NO_zeroing_on_larger_ @@ -88,8 +85,7 @@ extern "C" { #ifndef _f_memory_NO_zeroing_on_larger_ 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((void *) (((uint8_t *) new_pointer) + (type_size * length_old)), 0, type_size * (length_new - length_old)); } #endif // _f_memory_NO_zeroing_on_larger_