From 853fc668f5a61524f874754d57530d28dbdb4718 Mon Sep 17 00:00:00 2001 From: hasufell Date: Sun, 25 May 2014 19:00:10 +0200 Subject: [PATCH] MEM: add REALLOC macro --- src/mem.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/mem.h b/src/mem.h index 201d1fc..42e9a50 100644 --- a/src/mem.h +++ b/src/mem.h @@ -30,6 +30,23 @@ #include + +/** + * Realloc macro which checks if reallocation + * worked via a temporary pointer. + */ +#define REALLOC(ptr, size) \ +{ \ + void *tmp_ptr = NULL; \ + tmp_ptr = realloc(ptr, size); \ + if (tmp_ptr == NULL) { \ + fprintf(stderr,"NULL Pointer in %s [%d]",__FILE__,__LINE__); \ + abort(); \ + } \ + ptr = tmp_ptr; \ +} + + void *ntru_malloc(size_t size); void *ntru_calloc(size_t nmemb, size_t size);