Dolda2000 GitWeb
/
ashd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f9db90c
)
lib: Use abort() instead of exit() when smalloc fails.
author
Fredrik Tolf
<fredrik@dolda2000.com>
Wed, 23 Nov 2016 16:58:04 +0000
(17:58 +0100)
committer
Fredrik Tolf
<fredrik@dolda2000.com>
Wed, 23 Nov 2016 16:58:04 +0000
(17:58 +0100)
lib/utils.h
patch
|
blob
|
blame
|
history
diff --git
a/lib/utils.h
b/lib/utils.h
index
4fdde3c
..
658eea2
100644
(file)
--- a/
lib/utils.h
+++ b/
lib/utils.h
@@
-8,8
+8,8
@@
#define max(a, b) (((b) > (a))?(b):(a))
#define min(a, b) (((b) < (a))?(b):(a))
#define max(a, b) (((b) > (a))?(b):(a))
#define min(a, b) (((b) < (a))?(b):(a))
-#define smalloc(size) ({void *__result__; ((__result__ = malloc(size)) == NULL)?({
exit(-1
); (void *)0;}):__result__;})
-#define srealloc(ptr, size) ({void *__result__; ((__result__ = realloc((ptr), (size))) == NULL)?({
exit(-1
); (void *)0;}):__result__;})
+#define smalloc(size) ({void *__result__; ((__result__ = malloc(size)) == NULL)?({
abort(
); (void *)0;}):__result__;})
+#define srealloc(ptr, size) ({void *__result__; ((__result__ = realloc((ptr), (size))) == NULL)?({
abort(
); (void *)0;}):__result__;})
#define szmalloc(size) memset(smalloc(size), 0, size)
#define sstrdup(str) ({const char *__strbuf__ = (str); strcpy(smalloc(strlen(__strbuf__) + 1), __strbuf__);})
#define omalloc(o) ((o) = szmalloc(sizeof(*(o))))
#define szmalloc(size) memset(smalloc(size), 0, size)
#define sstrdup(str) ({const char *__strbuf__ = (str); strcpy(smalloc(strlen(__strbuf__) + 1), __strbuf__);})
#define omalloc(o) ((o) = szmalloc(sizeof(*(o))))