From 9de2840b9fe92c077e23832c3184c2c9a558839c Mon Sep 17 00:00:00 2001 From: Loup Vaillant Date: Sat, 14 Jul 2018 13:06:54 +0200 Subject: [PATCH] free(NULL) was not undefined after all Reverts 79f8285ea6cae0db2e906bf3eb65c8fcadabdaf8 This simplifies the test suite a tiny bit. Fixes #104 --- tests/test.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/tests/test.c b/tests/test.c index dd617a7..9bbbd3c 100644 --- a/tests/test.c +++ b/tests/test.c @@ -34,13 +34,6 @@ static void* alloc(size_t size) return buf; } -static void dealloc(void *ptr) -{ - if (ptr != 0) { - free(ptr); - } -} - typedef struct { u8 *buf; size_t size; @@ -80,11 +73,11 @@ static int test(void (*f)(const vector[], vector*), if (out.size != 0) { status |= memcmp(out.buf, expected.buf, out.size); } - dealloc(out.buf); + free(out.buf); idx += nb_inputs + 1; nb_tests++; } - dealloc(in); + free(in); printf("%s %4d tests: %s\n", status != 0 ? "FAILED" : "OK", nb_tests, name); return status; @@ -170,7 +163,7 @@ static void argon2i(const vector in[], vector *out) salt ->buf, salt ->size, key ->buf, key ->size, ad ->buf, ad ->size); - dealloc(work_area); + free(work_area); } static void x25519(const vector in[], vector *out) @@ -563,7 +556,7 @@ static int p_argon2i_easy() password, 32, salt, 16, 0, 0, 0, 0); crypto_argon2i(hash_easy, 32, work_area, 8, 1, password, 32, salt, 16); status |= memcmp(hash_general, hash_easy, 32); - dealloc(work_area); + free(work_area); printf("%s: Argon2i (easy interface)\n", status != 0 ? "FAILED" : "OK"); return status; } @@ -595,8 +588,8 @@ static int p_argon2i_overlap() work_area + ad_offset, 32); status |= memcmp(hash1, hash2, 32); } - dealloc(work_area); - dealloc(clean_work_area); + free(work_area); + free(clean_work_area); printf("%s: Argon2i (overlaping i/o)\n", status != 0 ? "FAILED" : "OK"); return status; } -- 2.47.3