aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig/util.c
diff options
context:
space:
mode:
authorAlan Cox <alan@linux.intel.com>2012-11-06 09:32:08 -0500
committerMichal Marek <mmarek@suse.cz>2012-11-20 06:12:47 -0500
commit177acf78468bf5c359bcb8823ee3bd48b04b8380 (patch)
tree08bd5614d4147060d25278aa54e8f8bab9794677 /scripts/kconfig/util.c
parent9a926d4354d84e424e738a6d401328340400331b (diff)
kconfig: Fix malloc handling in conf tools
(and get them out of the noise in the audit work) Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Michal Marek <mmarek@suse.cz>
Diffstat (limited to 'scripts/kconfig/util.c')
-rw-r--r--scripts/kconfig/util.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c
index d0b8b2318e48..6e7fbf196809 100644
--- a/scripts/kconfig/util.c
+++ b/scripts/kconfig/util.c
@@ -23,7 +23,7 @@ struct file *file_lookup(const char *name)
23 } 23 }
24 } 24 }
25 25
26 file = malloc(sizeof(*file)); 26 file = xmalloc(sizeof(*file));
27 memset(file, 0, sizeof(*file)); 27 memset(file, 0, sizeof(*file));
28 file->name = file_name; 28 file->name = file_name;
29 file->next = file_list; 29 file->next = file_list;
@@ -81,7 +81,7 @@ int file_write_dep(const char *name)
81struct gstr str_new(void) 81struct gstr str_new(void)
82{ 82{
83 struct gstr gs; 83 struct gstr gs;
84 gs.s = malloc(sizeof(char) * 64); 84 gs.s = xmalloc(sizeof(char) * 64);
85 gs.len = 64; 85 gs.len = 64;
86 gs.max_width = 0; 86 gs.max_width = 0;
87 strcpy(gs.s, "\0"); 87 strcpy(gs.s, "\0");
@@ -138,3 +138,22 @@ const char *str_get(struct gstr *gs)
138 return gs->s; 138 return gs->s;
139} 139}
140 140
141void *xmalloc(size_t size)
142{
143 void *p = malloc(size);
144 if (p)
145 return p;
146 fprintf(stderr, "Out of memory.\n");
147 exit(1);
148}
149
150void *xcalloc(size_t nmemb, size_t size)
151{
152 void *p = calloc(nmemb, size);
153 if (p)
154 return p;
155 fprintf(stderr, "Out of memory.\n");
156 exit(1);
157}
158
159