summaryrefslogtreecommitdiff
path: root/scripts/kconfig
diff options
context:
space:
mode:
authorMasahiro Yamada <masahiroy@kernel.org>2024-08-12 21:48:50 +0900
committerMasahiro Yamada <masahiroy@kernel.org>2024-09-01 20:34:48 +0900
commita9d83d74783b00f9189c14180f77bbed133b092c (patch)
treefaed29f1db80ea66727d6d9fd58b4147959359d0 /scripts/kconfig
parent96490176f1e11947be2bdd2700075275e2c27310 (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')
-rw-r--r--scripts/kconfig/confdata.c1
-rw-r--r--scripts/kconfig/expr.c1
-rw-r--r--scripts/kconfig/lexer.l1
-rw-r--r--scripts/kconfig/lkc.h5
-rw-r--r--scripts/kconfig/mconf.c1
-rw-r--r--scripts/kconfig/menu.c1
-rw-r--r--scripts/kconfig/nconf.c1
-rw-r--r--scripts/kconfig/nconf.gui.c1
-rw-r--r--scripts/kconfig/parser.y1
-rw-r--r--scripts/kconfig/preprocess.c1
-rw-r--r--scripts/kconfig/qconf.cc1
-rw-r--r--scripts/kconfig/symbol.c1
-rw-r--r--scripts/kconfig/util.c50
13 files changed, 12 insertions, 54 deletions
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 76193ce5a792..d8849dfb06db 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -18,6 +18,7 @@
#include <time.h>
#include <unistd.h>
+#include <xalloc.h>
#include "internal.h"
#include "lkc.h"
diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c
index c349da7fe3f8..a16451347f63 100644
--- a/scripts/kconfig/expr.c
+++ b/scripts/kconfig/expr.c
@@ -9,6 +9,7 @@
#include <stdlib.h>
#include <string.h>
+#include <xalloc.h>
#include "lkc.h"
#define DEBUG_EXPR 0
diff --git a/scripts/kconfig/lexer.l b/scripts/kconfig/lexer.l
index 8dd597c4710d..9c2cdfc33c6f 100644
--- a/scripts/kconfig/lexer.l
+++ b/scripts/kconfig/lexer.l
@@ -13,6 +13,7 @@
#include <stdlib.h>
#include <string.h>
+#include <xalloc.h>
#include "lkc.h"
#include "preprocess.h"
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index 401bdf36323a..ddfb2b1cb737 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -53,11 +53,6 @@ static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out)
/* util.c */
unsigned int strhash(const char *s);
const char *file_lookup(const char *name);
-void *xmalloc(size_t size);
-void *xcalloc(size_t nmemb, size_t size);
-void *xrealloc(void *p, size_t size);
-char *xstrdup(const char *s);
-char *xstrndup(const char *s, size_t n);
/* lexer.l */
int yylex(void);
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index 3887eac75289..84ea9215c0a7 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -20,6 +20,7 @@
#include <unistd.h>
#include <list.h>
+#include <xalloc.h>
#include "lkc.h"
#include "lxdialog/dialog.h"
#include "mnconf-common.h"
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index 854edeb4d2db..f61327fabead 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -9,6 +9,7 @@
#include <string.h>
#include <list.h>
+#include <xalloc.h>
#include "lkc.h"
#include "internal.h"
diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c
index b91ca47e9e9a..063b4f7ccbdb 100644
--- a/scripts/kconfig/nconf.c
+++ b/scripts/kconfig/nconf.c
@@ -12,6 +12,7 @@
#include <stdlib.h>
#include <list.h>
+#include <xalloc.h>
#include "lkc.h"
#include "mnconf-common.h"
#include "nconf.h"
diff --git a/scripts/kconfig/nconf.gui.c b/scripts/kconfig/nconf.gui.c
index 25a7263ef3c8..72b605efe549 100644
--- a/scripts/kconfig/nconf.gui.c
+++ b/scripts/kconfig/nconf.gui.c
@@ -4,6 +4,7 @@
*
* Derived from menuconfig.
*/
+#include <xalloc.h>
#include "nconf.h"
#include "lkc.h"
diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y
index 2d5e5ed56aba..1ad60f9e164e 100644
--- a/scripts/kconfig/parser.y
+++ b/scripts/kconfig/parser.y
@@ -11,6 +11,7 @@
#include <string.h>
#include <stdbool.h>
+#include <xalloc.h>
#include "lkc.h"
#include "internal.h"
#include "preprocess.h"
diff --git a/scripts/kconfig/preprocess.c b/scripts/kconfig/preprocess.c
index 67d1fb95c491..783abcaa5cc5 100644
--- a/scripts/kconfig/preprocess.c
+++ b/scripts/kconfig/preprocess.c
@@ -11,6 +11,7 @@
#include <array_size.h>
#include <list.h>
+#include <xalloc.h>
#include "internal.h"
#include "lkc.h"
#include "preprocess.h"
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index 88797d174261..97fce13e551e 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -22,6 +22,7 @@
#include <stdlib.h>
+#include <xalloc.h>
#include "lkc.h"
#include "qconf.h"
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index d75665f3dfa2..6793f016af5e 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -9,6 +9,7 @@
#include <string.h>
#include <regex.h>
+#include <xalloc.h>
#include "internal.h"
#include "lkc.h"
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);
-}