diff options
author | Bryan Hundven <bryanhundven@gmail.com> | 2015-09-01 16:11:30 -0700 |
---|---|---|
committer | Bryan Hundven <bryanhundven@gmail.com> | 2015-09-03 19:00:28 -0700 |
commit | 0cffa79d9fb3d5476d7a1dbeda617aea7a6851b2 (patch) | |
tree | 7339c7fff49ed2cd2e06c042bc1bc35a20f5a381 /kconfig/util.c | |
parent | 74b09f9c4a07a8f561001f4a727259b2d5eced77 (diff) | |
download | crosstool-ng-0cffa79d9fb3d5476d7a1dbeda617aea7a6851b2.tar.gz crosstool-ng-0cffa79d9fb3d5476d7a1dbeda617aea7a6851b2.tar.bz2 crosstool-ng-0cffa79d9fb3d5476d7a1dbeda617aea7a6851b2.zip |
kconfig: Update kconfig. Sync with Linux-4.2
This change updates the kconfig utility to what is shipped with 4.2.0.
Signed-off-by: Bryan Hundven <bryanhundven@gmail.com>
Diffstat (limited to 'kconfig/util.c')
-rw-r--r-- | kconfig/util.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/kconfig/util.c b/kconfig/util.c index 6330cc87..0e760424 100644 --- a/kconfig/util.c +++ b/kconfig/util.c @@ -5,6 +5,8 @@ * Released under the terms of the GNU GPL v2.0. */ +#include <stdarg.h> +#include <stdlib.h> #include <string.h> #include "lkc.h" @@ -21,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; @@ -79,23 +81,13 @@ 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"); return gs; } -/* Allocate and assign growable string */ -struct gstr str_assign(const char *s) -{ - struct gstr gs; - gs.s = strdup(s); - gs.len = strlen(s) + 1; - gs.max_width = 0; - return gs; -} - /* Free storage for growable string */ void str_free(struct gstr *gs) { @@ -136,3 +128,20 @@ 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); +} |