From 42e233eab7e6f5eb1a63545c526aa7dd34945bef Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Thu, 5 Feb 2015 12:07:50 +0100 Subject: xmalloc: Remove unnecessary NULL check before realloc() If realloc() is passed NULL as its first argument, it behaves like malloc(), so the check for ptr begin NULL is not necessary Signed-off-by: Tobias Klauser --- xmalloc.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/xmalloc.c b/xmalloc.c index bdb6234..18972fb 100644 --- a/xmalloc.c +++ b/xmalloc.c @@ -108,11 +108,7 @@ void *xrealloc(void *ptr, size_t nmemb, size_t size) if (unlikely(((size_t) ~0) / nmemb < size)) panic("xrealloc: nmemb * size > SIZE_T_MAX\n"); - if (ptr == NULL) - new_ptr = malloc(new_size); - else - new_ptr = realloc(ptr, new_size); - + new_ptr = realloc(ptr, new_size); if (unlikely(new_ptr == NULL)) panic("xrealloc: out of memory (new_size %zu bytes)\n", new_size); -- cgit v1.2.3-54-g00ecf