summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2015-02-05 12:07:50 +0100
committerTobias Klauser <tklauser@distanz.ch>2015-02-05 12:07:50 +0100
commit42e233eab7e6f5eb1a63545c526aa7dd34945bef (patch)
treeb632610418a3cbea2fe7dec5552771f4f734ab6c
parent50802193c013bf79411111cf393b3aafa5ad2dc5 (diff)
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 <tklauser@distanz.ch>
-rw-r--r--xmalloc.c6
1 files changed, 1 insertions, 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);