Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

+65 -54
+53
scripts/include/xalloc.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only */ 2 + 3 + #ifndef XALLOC_H 4 + #define XALLOC_H 5 + 6 + #include <stdlib.h> 7 + #include <string.h> 8 + 9 + static inline void *xmalloc(size_t size) 10 + { 11 + void *p = malloc(size); 12 + 13 + if (!p) 14 + exit(1); 15 + return p; 16 + } 17 + 18 + static inline void *xcalloc(size_t nmemb, size_t size) 19 + { 20 + void *p = calloc(nmemb, size); 21 + 22 + if (!p) 23 + exit(1); 24 + return p; 25 + } 26 + 27 + static inline void *xrealloc(void *p, size_t size) 28 + { 29 + p = realloc(p, size); 30 + if (!p) 31 + exit(1); 32 + return p; 33 + } 34 + 35 + static inline char *xstrdup(const char *s) 36 + { 37 + char *p = strdup(s); 38 + 39 + if (!p) 40 + exit(1); 41 + return p; 42 + } 43 + 44 + static inline char *xstrndup(const char *s, size_t n) 45 + { 46 + char *p = strndup(s, n); 47 + 48 + if (!p) 49 + exit(1); 50 + return p; 51 + } 52 + 53 + #endif /* XALLOC_H */
+1
scripts/kconfig/confdata.c
··· 18 18 #include <time.h> 19 19 #include <unistd.h> 20 20 21 + #include <xalloc.h> 21 22 #include "internal.h" 22 23 #include "lkc.h" 23 24
+1
scripts/kconfig/expr.c
··· 9 9 #include <stdlib.h> 10 10 #include <string.h> 11 11 12 + #include <xalloc.h> 12 13 #include "lkc.h" 13 14 14 15 #define DEBUG_EXPR 0
+1
scripts/kconfig/lexer.l
··· 13 13 #include <stdlib.h> 14 14 #include <string.h> 15 15 16 + #include <xalloc.h> 16 17 #include "lkc.h" 17 18 #include "preprocess.h" 18 19
-5
scripts/kconfig/lkc.h
··· 53 53 /* util.c */ 54 54 unsigned int strhash(const char *s); 55 55 const char *file_lookup(const char *name); 56 - void *xmalloc(size_t size); 57 - void *xcalloc(size_t nmemb, size_t size); 58 - void *xrealloc(void *p, size_t size); 59 - char *xstrdup(const char *s); 60 - char *xstrndup(const char *s, size_t n); 61 56 62 57 /* lexer.l */ 63 58 int yylex(void);
+1
scripts/kconfig/mconf.c
··· 20 20 #include <unistd.h> 21 21 22 22 #include <list.h> 23 + #include <xalloc.h> 23 24 #include "lkc.h" 24 25 #include "lxdialog/dialog.h" 25 26 #include "mnconf-common.h"
+1
scripts/kconfig/menu.c
··· 9 9 #include <string.h> 10 10 11 11 #include <list.h> 12 + #include <xalloc.h> 12 13 #include "lkc.h" 13 14 #include "internal.h" 14 15
+1
scripts/kconfig/nconf.c
··· 12 12 #include <stdlib.h> 13 13 14 14 #include <list.h> 15 + #include <xalloc.h> 15 16 #include "lkc.h" 16 17 #include "mnconf-common.h" 17 18 #include "nconf.h"
+1
scripts/kconfig/nconf.gui.c
··· 4 4 * 5 5 * Derived from menuconfig. 6 6 */ 7 + #include <xalloc.h> 7 8 #include "nconf.h" 8 9 #include "lkc.h" 9 10
+1
scripts/kconfig/parser.y
··· 11 11 #include <string.h> 12 12 #include <stdbool.h> 13 13 14 + #include <xalloc.h> 14 15 #include "lkc.h" 15 16 #include "internal.h" 16 17 #include "preprocess.h"
+1
scripts/kconfig/preprocess.c
··· 11 11 12 12 #include <array_size.h> 13 13 #include <list.h> 14 + #include <xalloc.h> 14 15 #include "internal.h" 15 16 #include "lkc.h" 16 17 #include "preprocess.h"
+1
scripts/kconfig/qconf.cc
··· 22 22 23 23 #include <stdlib.h> 24 24 25 + #include <xalloc.h> 25 26 #include "lkc.h" 26 27 #include "qconf.h" 27 28
+1
scripts/kconfig/symbol.c
··· 9 9 #include <string.h> 10 10 #include <regex.h> 11 11 12 + #include <xalloc.h> 12 13 #include "internal.h" 13 14 #include "lkc.h" 14 15
+1 -49
scripts/kconfig/util.c
··· 9 9 #include <string.h> 10 10 11 11 #include <hashtable.h> 12 + #include <xalloc.h> 12 13 #include "lkc.h" 13 14 14 15 unsigned int strhash(const char *s) ··· 102 101 char *str_get(const struct gstr *gs) 103 102 { 104 103 return gs->s; 105 - } 106 - 107 - void *xmalloc(size_t size) 108 - { 109 - void *p = malloc(size); 110 - if (p) 111 - return p; 112 - fprintf(stderr, "Out of memory.\n"); 113 - exit(1); 114 - } 115 - 116 - void *xcalloc(size_t nmemb, size_t size) 117 - { 118 - void *p = calloc(nmemb, size); 119 - if (p) 120 - return p; 121 - fprintf(stderr, "Out of memory.\n"); 122 - exit(1); 123 - } 124 - 125 - void *xrealloc(void *p, size_t size) 126 - { 127 - p = realloc(p, size); 128 - if (p) 129 - return p; 130 - fprintf(stderr, "Out of memory.\n"); 131 - exit(1); 132 - } 133 - 134 - char *xstrdup(const char *s) 135 - { 136 - char *p; 137 - 138 - p = strdup(s); 139 - if (p) 140 - return p; 141 - fprintf(stderr, "Out of memory.\n"); 142 - exit(1); 143 - } 144 - 145 - char *xstrndup(const char *s, size_t n) 146 - { 147 - char *p; 148 - 149 - p = strndup(s, n); 150 - if (p) 151 - return p; 152 - fprintf(stderr, "Out of memory.\n"); 153 - exit(1); 154 104 }