From e0ac05034137f7beaa24f371d4b8bd71584d1a87 Mon Sep 17 00:00:00 2001 From: Thomas Schmucker Date: Fri, 26 Jun 2020 09:03:59 +0200 Subject: Vereinfache das Standard-Memory-Handling: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - wir verzichten auf "explicit_bzero()". Wenn ein Client diese Funktion bei "free()" benötigt, kann dieser einen Custum-Allocator installieren. - Vereinfache den Code bei einem Multiplikationsüberlauf ein wenig. --- csv.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'csv.c') diff --git a/csv.c b/csv.c index f154c12..a4f9b51 100644 --- a/csv.c +++ b/csv.c @@ -25,28 +25,22 @@ csv_mem_allocate(size_t n, size_t sz, void *cb_arg) static void * csv_mem_reallocate(void *ptr, size_t n, size_t sz, void *cb_arg) { - size_t len; - (void) cb_arg; - if ( !__builtin_mul_overflow(n, sz, &len) ) { - return realloc(ptr, len); + size_t len; + if ( __builtin_mul_overflow(n, sz, &len) ) { + return NULL; } - return NULL; + return realloc(ptr, len); } static void csv_mem_free(void *ptr, size_t n, size_t sz, void *cb_arg) { - size_t len; - - void explicit_bzero(void *b, size_t len); - + (void) n; + (void) sz; (void) cb_arg; - if ( !__builtin_mul_overflow(n, sz, &len) ) { - explicit_bzero(ptr, len); - } free(ptr); } -- cgit v1.3