projects
/
carl9170fw.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
kconfig: add xrealloc() helper
[carl9170fw.git]
/
config
/
util.c
diff --git
a/config/util.c
b/config/util.c
index 0e76042473ccd3633aa0870da3cce23e0b1788c6..138894ef49ea18545468de9b1021c58505d36454 100644
(file)
--- a/
config/util.c
+++ b/
config/util.c
@@
-104,7
+104,7
@@
void str_append(struct gstr *gs, const char *s)
if (s) {
l = strlen(gs->s) + strlen(s) + 1;
if (l > gs->len) {
if (s) {
l = strlen(gs->s) + strlen(s) + 1;
if (l > gs->len) {
- gs->s
=
realloc(gs->s, l);
+ gs->s
= x
realloc(gs->s, l);
gs->len = l;
}
strcat(gs->s, s);
gs->len = l;
}
strcat(gs->s, s);
@@
-145,3
+145,12
@@
void *xcalloc(size_t nmemb, size_t size)
fprintf(stderr, "Out of memory.\n");
exit(1);
}
fprintf(stderr, "Out of memory.\n");
exit(1);
}
+
+void *xrealloc(void *p, size_t size)
+{
+ p = realloc(p, size);
+ if (p)
+ return p;
+ fprintf(stderr, "Out of memory.\n");
+ exit(1);
+}