diff options
Diffstat (limited to 'xmalloc.c')
-rw-r--r-- | xmalloc.c | 13 |
1 files changed, 5 insertions, 8 deletions
@@ -1,6 +1,7 @@ /* * netsniff-ng - the packet sniffing beast * Copyright 2009, 2010, 2011, 2012 Daniel Borkmann. + * Copyright 2014, 2015 Tobias Klauser * Subject to the GPL, version 2. */ @@ -98,20 +99,16 @@ void *xmemdupz(const void *data, size_t len) return memcpy(xmallocz(len), data, len); } -void *xrealloc(void *ptr, size_t nmemb, size_t size) +void *xrealloc(void *ptr, size_t size) { void *new_ptr; - size_t new_size = nmemb * size; - if (unlikely(new_size == 0)) + if (unlikely(size == 0)) panic("xrealloc: zero size\n"); - if (unlikely(((size_t) ~0) / nmemb < size)) - panic("xrealloc: nmemb * size > SIZE_T_MAX\n"); - new_ptr = realloc(ptr, new_size); + new_ptr = realloc(ptr, size); if (unlikely(new_ptr == NULL)) - panic("xrealloc: out of memory (new_size %zu bytes)\n", - new_size); + panic("xrealloc: out of memory (allocating %zu bytes)\n", size); return new_ptr; } |