{
GVariant *dbus_ret;
int input_id, ret = 0;
- char *input_device_name;
+ char *input_device_name = NULL;
pid_t pid;
g_variant_get(param, "(i)", &input_id);
#include "shared/log.h"
#include "input-device-manager.h"
-static struct input_device_element {
+struct input_device_element {
int id;
int device_default;
char *name;
static GHashTable *g_input_device_list;
+static void cleanup_input_device_element(gpointer data)
+{
+ struct input_device_element *input_device_elem = data;
+ free(input_device_elem->name);
+ free(input_device_elem);
+}
+
static void destroy_input_device_hashtable_value(gpointer data)
{
- g_list_free((GList*)data);
+ g_list_free_full(data, cleanup_input_device_element);
}
int input_devman_init(void)
input_device_elem = malloc(sizeof(struct input_device_element));
if (!input_device_elem) {
_E("Failed to malloc input device element");
+ g_free(hash_key);
return -ENOMEM;
}
input_device_elem->id = input_device_id;
#define INPUT_CONF_PATH "/hal/etc/deviced/input.conf"
-static struct input_device_info {
+struct input_device_info {
int input_device_type;
int input_device_id;
char *input_device_name;
} else if (MATCH(prop->key, "InputDeviceId")) {
sscanf(prop->value, "%d", (&input_dev_info->input_device_id));
} else if (MATCH(prop->key, "InputDeviceName")) {
- input_dev_info->input_device_name = calloc(sizeof(prop->value), sizeof(char));
- strcpy(input_dev_info->input_device_name, prop->value);
+ int str_len = sizeof(prop->value);
+ input_dev_info->input_device_name = strndup(prop->value, str_len);
} else if (MATCH(prop->key, "InputDeviceDefault")) {
if (MATCH(prop->value, "yes"))
input_dev_info->input_device_default = 1;