From b5cda2ab3a068da5571cc4e81c4a8a1ac7f2c947 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 1d892e0..fddab06 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 (f_void_p) 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 (f_void_p) having arithmetic issues memset(((char *)*pointer) + new_length, 0, type * (old_length - new_length)); } -- 1.8.3.1