From 8d1deb9881124c7568b42a8d7851d257a483dce3 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Wed, 24 Jul 2019 23:43:28 -0500 Subject: [PATCH] Cleanup: fix comments and remove commented out memset According to the standards that I have read, calloc() guarantees zero'd memory, so memset is not needed. It so happens that the memset was commented out already, so just remove it. There are some memset related comments that incorrectly use the word 'bool' when the word 'char' should be used. --- level_0/f_memory/c/memory.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/level_0/f_memory/c/memory.c b/level_0/f_memory/c/memory.c index 7a224e9..a4963c7 100644 --- a/level_0/f_memory/c/memory.c +++ b/level_0/f_memory/c/memory.c @@ -28,7 +28,6 @@ extern "C"{ *pointer = calloc(type, length); if (*pointer) { - //memset(*pointer, 0, type * length); return f_none; } @@ -108,7 +107,7 @@ extern "C"{ if (new_pointer) { if (new_pointer != *pointer) { if (new_length > old_length) { - // bool * is of a data type size of 1, casting it to bool should result in a single-length increment + // char * is of a data type size of 1, casting it to char should result in a single-length increment // this is done to avoid problems with (void *) having arithmetic issues memset(((char *) new_pointer) + (type * old_length), 0, type * (new_length - old_length)); } @@ -149,7 +148,7 @@ extern "C"{ if (old_length > 0) { if (new_length < old_length) { - // bool * is of a data type size of 1, casting it to bool should result in a single-length increment + // char * is of a data type size of 1, casting it to char should result in a single-length increment // this is done to avoid problems with (void *) having arithmetic issues memset(((char *)*pointer) + new_length, 0, type * (old_length - new_length)); } -- 1.8.3.1