summaryrefslogtreecommitdiff
path: root/xmalloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'xmalloc.c')
-rw-r--r--xmalloc.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/xmalloc.c b/xmalloc.c
index 18972fb..75319ff 100644
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -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;
}