static int parse_event_action(const struct parse_result *result, void *data)
{
struct input_config *ic;
- struct input_parse_event_action *input_event_action;
+ struct input_parse_event_action input_event_action;
GHashTable *hash_table = (GHashTable *) data;
if (!result || !result->props)
_D("Input section=%s", result->section);
- input_event_action = calloc(1, sizeof(struct input_parse_event_action));
- if (!input_event_action)
- return 0;
-
- input_event_action->ieu = calloc(1, sizeof(struct input_event_unit));
- if (!input_event_action->ieu)
- return 0;
+ input_event_action.ieu = calloc(1, sizeof(struct input_event_unit));
+ if (!input_event_action.ieu)
+ goto fail_mem_alloc;
- input_event_action->hash_table_key_infos = hash_table;
- g_list_foreach(result->props, parse_event_action_property, input_event_action);
+ input_event_action.hash_table_key_infos = hash_table;
+ g_list_foreach(result->props, parse_event_action_property, &input_event_action);
- ic = find_input_config(input_event_action->ieu->keycode);
+ ic = find_input_config(input_event_action.ieu->keycode);
if (!ic) {
ic = calloc(1, sizeof(struct input_config));
if (!ic)
- return -ENOMEM;
- ic->keycode = input_event_action->ieu->keycode;
+ goto fail_mem_alloc;
+ ic->keycode = input_event_action.ieu->keycode;
SYS_G_LIST_APPEND(input_config_list, ic);
}
- SYS_G_LIST_APPEND(ic->event_list, input_event_action->ieu);
+ SYS_G_LIST_APPEND(ic->event_list, input_event_action.ieu);
return 0;
+
+fail_mem_alloc:
+ if (input_event_action.ieu)
+ free(input_event_action.ieu);
+
+ return -ENOMEM;
}
/* return 1 if the condition met, otherwise return 0 */