diff options
author | Masahiro Yamada <yamada.masahiro@socionext.com> | 2018-02-08 17:19:07 +0100 |
---|---|---|
committer | Masahiro Yamada <yamada.masahiro@socionext.com> | 2018-02-10 03:26:04 +0100 |
commit | d717f24d8c68081caae2374cf5ea6c4e62c490fc (patch) | |
tree | 325008cf6d2fea2dfa15e4d49ae4d4d79fb1ff2b /scripts/kconfig/util.c | |
parent | kconfig: send error messages to stderr (diff) | |
download | linux-d717f24d8c68081caae2374cf5ea6c4e62c490fc.tar.xz linux-d717f24d8c68081caae2374cf5ea6c4e62c490fc.zip |
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 '')
-rw-r--r-- | scripts/kconfig/util.c | 11 |
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) if (s) { l = strlen(gs->s) + strlen(s) + 1; if (l > gs->len) { - gs->s = realloc(gs->s, l); + gs->s = xrealloc(gs->s, l); 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); } + +void *xrealloc(void *p, size_t size) +{ + p = realloc(p, size); + if (p) + return p; + fprintf(stderr, "Out of memory.\n"); + exit(1); +} |