Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 323881
b: refs/heads/master
c: 87162d8
h: refs/heads/master
i:
  323879: a8b51c9
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo committed Sep 24, 2012
1 parent b8e8697 commit 56001e7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 31 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: 0dbca1e364aba20dba70d88c083239c5152440ac
refs/heads/master: 87162d816f5f344d72e25249acd9b823b646a5c9
44 changes: 14 additions & 30 deletions trunk/tools/lib/traceevent/event-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,7 @@ void breakpoint(void)

struct print_arg *alloc_arg(void)
{
struct print_arg *arg;

arg = malloc_or_die(sizeof(*arg));
if (!arg)
return NULL;
memset(arg, 0, sizeof(*arg));

return arg;
return calloc(1, sizeof(struct print_arg));
}

struct cmdline {
Expand Down Expand Up @@ -619,14 +612,7 @@ void pevent_print_printk(struct pevent *pevent)

static struct event_format *alloc_event(void)
{
struct event_format *event;

event = malloc(sizeof(*event));
if (!event)
return NULL;
memset(event, 0, sizeof(*event));

return event;
return calloc(1, sizeof(struct event_format));
}

static void add_event(struct pevent *pevent, struct event_format *event)
Expand Down Expand Up @@ -1240,8 +1226,10 @@ static int event_read_fields(struct event_format *event, struct format_field **f

last_token = token;

field = malloc_or_die(sizeof(*field));
memset(field, 0, sizeof(*field));
field = calloc(1, sizeof(*field));
if (!field)
goto fail;

field->event = event;

/* read the rest of the type */
Expand Down Expand Up @@ -2181,8 +2169,9 @@ process_fields(struct event_format *event, struct print_flag_sym **list, char **
if (test_type_token(type, token, EVENT_DELIM, ","))
goto out_free;

field = malloc_or_die(sizeof(*field));
memset(field, 0, sizeof(*field));
field = calloc(1, sizeof(*field));
if (!field)
goto out_free;

value = arg_eval(arg);
if (value == NULL)
Expand Down Expand Up @@ -5106,12 +5095,11 @@ int pevent_register_print_function(struct pevent *pevent,
remove_func_handler(pevent, name);
}

func_handle = malloc(sizeof(*func_handle));
func_handle = calloc(1, sizeof(*func_handle));
if (!func_handle) {
do_warning("Failed to allocate function handler");
return PEVENT_ERRNO__MEM_ALLOC_FAILED;
}
memset(func_handle, 0, sizeof(*func_handle));

func_handle->ret_type = ret_type;
func_handle->name = strdup(name);
Expand Down Expand Up @@ -5210,13 +5198,12 @@ int pevent_register_event_handler(struct pevent *pevent,

not_found:
/* Save for later use. */
handle = malloc(sizeof(*handle));
handle = calloc(1, sizeof(*handle));
if (!handle) {
do_warning("Failed to allocate event handler");
return PEVENT_ERRNO__MEM_ALLOC_FAILED;
}

memset(handle, 0, sizeof(*handle));
handle->id = id;
if (event_name)
handle->event_name = strdup(event_name);
Expand Down Expand Up @@ -5245,13 +5232,10 @@ int pevent_register_event_handler(struct pevent *pevent,
*/
struct pevent *pevent_alloc(void)
{
struct pevent *pevent;
struct pevent *pevent = calloc(1, sizeof(*pevent));

pevent = malloc(sizeof(*pevent));
if (!pevent)
return NULL;
memset(pevent, 0, sizeof(*pevent));
pevent->ref_count = 1;
if (pevent)
pevent->ref_count = 1;

return pevent;
}
Expand Down

0 comments on commit 56001e7

Please sign in to comment.