summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-23 00:00:10 (GMT)
committerWerner Almesberger <werner@almesberger.net>2016-08-23 00:00:40 (GMT)
commitce690a463d1905b2aba8a04c29a248af66153681 (patch)
tree96072589d04ca8b1c536c6a0b5c8f58c7c2a21b1 /misc
parent8dfb6b2c9f722d70b30e5794fe20ce9450dd05d4 (diff)
downloadeeshow-ce690a463d1905b2aba8a04c29a248af66153681.zip
eeshow-ce690a463d1905b2aba8a04c29a248af66153681.tar.gz
eeshow-ce690a463d1905b2aba8a04c29a248af66153681.tar.bz2
eeshow/misc/util.h (realloc_size, realloc_type_n): get rid of bare "realloc"
Finally ! Shoulds have done this a long time ago.
Diffstat (limited to 'misc')
-rw-r--r--misc/util.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/misc/util.h b/misc/util.h
index 657c6d0..e9bc4f3 100644
--- a/misc/util.h
+++ b/misc/util.h
@@ -30,6 +30,18 @@
#define alloc_type(t) ((t *) alloc_size(sizeof(t)))
#define alloc_type_n(t, n) ((t *) alloc_size(sizeof(t) * (n)))
+
+#define realloc_size(p, s) \
+ ({ void *alloc_size_tmp = realloc((p), (s)); \
+ if (!alloc_size_tmp) { \
+ perror("realloc"); \
+ exit(1); \
+ } \
+ alloc_size_tmp; })
+
+#define realloc_type_n(p, t, n) ((t *) realloc_size((p), sizeof(t) * (n)))
+
+
#define stralloc(s) \
({ char *stralloc_tmp = strdup(s); \
if (!stralloc_tmp) { \