diff options
author | Masahiro Yamada <masahiroy@kernel.org> | 2024-08-12 21:48:50 +0900 |
---|---|---|
committer | Masahiro Yamada <masahiroy@kernel.org> | 2024-09-01 20:34:48 +0900 |
commit | a9d83d74783b00f9189c14180f77bbed133b092c (patch) | |
tree | faed29f1db80ea66727d6d9fd58b4147959359d0 /scripts/kconfig/util.c | |
parent | 96490176f1e11947be2bdd2700075275e2c27310 (diff) |
kbuild: split x*alloc() functions in kconfig to scripts/include/xalloc.h
These functions will be useful for other host programs.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Diffstat (limited to 'scripts/kconfig/util.c')
-rw-r--r-- | scripts/kconfig/util.c | 50 |
1 files changed, 1 insertions, 49 deletions
diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c index 696ff477671e..50698fff5b9d 100644 --- a/scripts/kconfig/util.c +++ b/scripts/kconfig/util.c @@ -9,6 +9,7 @@ #include <string.h> #include <hashtable.h> +#include <xalloc.h> #include "lkc.h" unsigned int strhash(const char *s) @@ -102,52 +103,3 @@ char *str_get(const struct gstr *gs) { return gs->s; } - -void *xmalloc(size_t size) -{ - void *p = malloc(size); - if (p) - return p; - fprintf(stderr, "Out of memory.\n"); - exit(1); -} - -void *xcalloc(size_t nmemb, size_t size) -{ - void *p = calloc(nmemb, size); - if (p) - return p; - 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); -} - -char *xstrdup(const char *s) -{ - char *p; - - p = strdup(s); - if (p) - return p; - fprintf(stderr, "Out of memory.\n"); - exit(1); -} - -char *xstrndup(const char *s, size_t n) -{ - char *p; - - p = strndup(s, n); - if (p) - return p; - fprintf(stderr, "Out of memory.\n"); - exit(1); -} |