Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 359231
b: refs/heads/master
c: 177acf7
h: refs/heads/master
i:
  359229: d20105f
  359227: c3c7fe1
  359223: 86b5398
  359215: 35a1176
  359199: fceb2e7
  359167: 417edc1
v: v3
  • Loading branch information
Alan Cox authored and Michal Marek committed Nov 20, 2012
1 parent 2048b02 commit 963d80a
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 20 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9a926d4354d84e424e738a6d401328340400331b
refs/heads/master: 177acf78468bf5c359bcb8823ee3bd48b04b8380
10 changes: 5 additions & 5 deletions trunk/scripts/kconfig/expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@

struct expr *expr_alloc_symbol(struct symbol *sym)
{
struct expr *e = calloc(1, sizeof(*e));
struct expr *e = xcalloc(1, sizeof(*e));
e->type = E_SYMBOL;
e->left.sym = sym;
return e;
}

struct expr *expr_alloc_one(enum expr_type type, struct expr *ce)
{
struct expr *e = calloc(1, sizeof(*e));
struct expr *e = xcalloc(1, sizeof(*e));
e->type = type;
e->left.expr = ce;
return e;
}

struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2)
{
struct expr *e = calloc(1, sizeof(*e));
struct expr *e = xcalloc(1, sizeof(*e));
e->type = type;
e->left.expr = e1;
e->right.expr = e2;
Expand All @@ -38,7 +38,7 @@ struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e

struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2)
{
struct expr *e = calloc(1, sizeof(*e));
struct expr *e = xcalloc(1, sizeof(*e));
e->type = type;
e->left.sym = s1;
e->right.sym = s2;
Expand Down Expand Up @@ -66,7 +66,7 @@ struct expr *expr_copy(const struct expr *org)
if (!org)
return NULL;

e = malloc(sizeof(*org));
e = xmalloc(sizeof(*org));
memcpy(e, org, sizeof(*org));
switch (org->type) {
case E_SYMBOL:
Expand Down
2 changes: 2 additions & 0 deletions trunk/scripts/kconfig/lkc.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ void menu_set_type(int type);
/* util.c */
struct file *file_lookup(const char *name);
int file_write_dep(const char *name);
void *xmalloc(size_t size);
void *xcalloc(size_t nmemb, size_t size);

struct gstr {
size_t len;
Expand Down
4 changes: 2 additions & 2 deletions trunk/scripts/kconfig/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void menu_add_entry(struct symbol *sym)
{
struct menu *menu;

menu = malloc(sizeof(*menu));
menu = xmalloc(sizeof(*menu));
memset(menu, 0, sizeof(*menu));
menu->sym = sym;
menu->parent = current_menu;
Expand Down Expand Up @@ -531,7 +531,7 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
location = menu;
}
if (head && location) {
jump = malloc(sizeof(struct jump_key));
jump = xmalloc(sizeof(struct jump_key));

if (menu_is_visible(prop->menu)) {
/*
Expand Down
12 changes: 6 additions & 6 deletions trunk/scripts/kconfig/symbol.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,11 +656,11 @@ bool sym_set_string_value(struct symbol *sym, const char *newval)
size = strlen(newval) + 1;
if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) {
size += 2;
sym->def[S_DEF_USER].val = val = malloc(size);
sym->def[S_DEF_USER].val = val = xmalloc(size);
*val++ = '0';
*val++ = 'x';
} else if (!oldval || strcmp(oldval, newval))
sym->def[S_DEF_USER].val = val = malloc(size);
sym->def[S_DEF_USER].val = val = xmalloc(size);
else
return true;

Expand Down Expand Up @@ -812,7 +812,7 @@ struct symbol *sym_lookup(const char *name, int flags)
hash = 0;
}

symbol = malloc(sizeof(*symbol));
symbol = xmalloc(sizeof(*symbol));
memset(symbol, 0, sizeof(*symbol));
symbol->name = new_name;
symbol->type = S_UNKNOWN;
Expand Down Expand Up @@ -863,7 +863,7 @@ const char *sym_expand_string_value(const char *in)
size_t reslen;

reslen = strlen(in) + 1;
res = malloc(reslen);
res = xmalloc(reslen);
res[0] = '\0';

while ((src = strchr(in, '$'))) {
Expand Down Expand Up @@ -921,7 +921,7 @@ const char *sym_escape_string_value(const char *in)
p++;
}

res = malloc(reslen);
res = xmalloc(reslen);
res[0] = '\0';

strcat(res, "\"");
Expand Down Expand Up @@ -1228,7 +1228,7 @@ struct property *prop_alloc(enum prop_type type, struct symbol *sym)
struct property *prop;
struct property **propp;

prop = malloc(sizeof(*prop));
prop = xmalloc(sizeof(*prop));
memset(prop, 0, sizeof(*prop));
prop->type = type;
prop->sym = sym;
Expand Down
23 changes: 21 additions & 2 deletions trunk/scripts/kconfig/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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);
}


8 changes: 4 additions & 4 deletions trunk/scripts/kconfig/zconf.l
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static void zconf_endfile(void);

static void new_string(void)
{
text = malloc(START_STRSIZE);
text = xmalloc(START_STRSIZE);
text_asize = START_STRSIZE;
text_size = 0;
*text = 0;
Expand All @@ -62,7 +62,7 @@ static void append_string(const char *str, int size)

static void alloc_string(const char *str, int size)
{
text = malloc(size + 1);
text = xmalloc(size + 1);
memcpy(text, str, size);
text[size] = 0;
}
Expand Down Expand Up @@ -288,7 +288,7 @@ void zconf_initscan(const char *name)
exit(1);
}

current_buf = malloc(sizeof(*current_buf));
current_buf = xmalloc(sizeof(*current_buf));
memset(current_buf, 0, sizeof(*current_buf));

current_file = file_lookup(name);
Expand All @@ -299,7 +299,7 @@ void zconf_nextfile(const char *name)
{
struct file *iter;
struct file *file = file_lookup(name);
struct buffer *buf = malloc(sizeof(*buf));
struct buffer *buf = xmalloc(sizeof(*buf));
memset(buf, 0, sizeof(*buf));

current_buf->state = YY_CURRENT_BUFFER;
Expand Down

0 comments on commit 963d80a

Please sign in to comment.