diff options
author | Alan Cox <alan@linux.intel.com> | 2012-11-06 14:32:08 +0000 |
---|---|---|
committer | Michal Marek <mmarek@suse.cz> | 2012-11-20 12:12:47 +0100 |
commit | 177acf78468bf5c359bcb8823ee3bd48b04b8380 (patch) | |
tree | 08bd5614d4147060d25278aa54e8f8bab9794677 /scripts/kconfig/util.c | |
parent | 9a926d4354d84e424e738a6d401328340400331b (diff) | |
download | blackbird-op-linux-177acf78468bf5c359bcb8823ee3bd48b04b8380.tar.gz blackbird-op-linux-177acf78468bf5c359bcb8823ee3bd48b04b8380.zip |
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.c | 23 |
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) } } - file = malloc(sizeof(*file)); + file = xmalloc(sizeof(*file)); memset(file, 0, sizeof(*file)); file->name = file_name; file->next = file_list; @@ -81,7 +81,7 @@ int file_write_dep(const char *name) struct gstr str_new(void) { struct gstr gs; - gs.s = malloc(sizeof(char) * 64); + gs.s = xmalloc(sizeof(char) * 64); gs.len = 64; gs.max_width = 0; strcpy(gs.s, "\0"); @@ -138,3 +138,22 @@ const char *str_get(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); +} + + |