1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2025-04-21 12:27:27 +03:00

eeshow/misc/util.h (realloc_size, realloc_type_n): get rid of bare "realloc"

Finally ! Shoulds have done this a long time ago.
This commit is contained in:
Werner Almesberger
2016-08-22 21:00:10 -03:00
parent 1b250bd467
commit 465a36fde5
9 changed files with 25 additions and 29 deletions

View File

@@ -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) { \