aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig/util.c
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2018-02-08 11:19:07 -0500
committerMasahiro Yamada <yamada.masahiro@socionext.com>2018-02-09 21:26:04 -0500
commitd717f24d8c68081caae2374cf5ea6c4e62c490fc (patch)
tree325008cf6d2fea2dfa15e4d49ae4d4d79fb1ff2b /scripts/kconfig/util.c
parent9e3e10c725360b9d07018cfcd5b7b6b7d325fae5 (diff)
kconfig: add xrealloc() helper
We already have xmalloc(), xcalloc(). Add xrealloc() as well to save tedious error handling. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Diffstat (limited to 'scripts/kconfig/util.c')
-rw-r--r--scripts/kconfig/util.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c
index 0e76042473cc..138894ef49ea 100644
--- a/scripts/kconfig/util.c
+++ b/scripts/kconfig/util.c
@@ -104,7 +104,7 @@ void str_append(struct gstr *gs, const char *s)
104 if (s) { 104 if (s) {
105 l = strlen(gs->s) + strlen(s) + 1; 105 l = strlen(gs->s) + strlen(s) + 1;
106 if (l > gs->len) { 106 if (l > gs->len) {
107 gs->s = realloc(gs->s, l); 107 gs->s = xrealloc(gs->s, l);
108 gs->len = l; 108 gs->len = l;
109 } 109 }
110 strcat(gs->s, s); 110 strcat(gs->s, s);
@@ -145,3 +145,12 @@ void *xcalloc(size_t nmemb, size_t size)
145 fprintf(stderr, "Out of memory.\n"); 145 fprintf(stderr, "Out of memory.\n");
146 exit(1); 146 exit(1);
147} 147}
148
149void *xrealloc(void *p, size_t size)
150{
151 p = realloc(p, size);
152 if (p)
153 return p;
154 fprintf(stderr, "Out of memory.\n");
155 exit(1);
156}