diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2015-02-05 12:07:50 +0100 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2015-02-05 12:07:50 +0100 |
commit | 42e233eab7e6f5eb1a63545c526aa7dd34945bef (patch) | |
tree | b632610418a3cbea2fe7dec5552771f4f734ab6c /xmalloc.c | |
parent | 50802193c013bf79411111cf393b3aafa5ad2dc5 (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>
Diffstat (limited to 'xmalloc.c')
-rw-r--r-- | xmalloc.c | 6 |
1 files changed, 1 insertions, 5 deletions
@@ -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); |