aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe ANDRE <jpeg@videolan.org>2015-03-25 15:29:49 -0700
committerJean-Philippe ANDRE <jpeg@videolan.org>2015-03-25 15:34:23 -0700
commit0ef41604e88b8a8224818824217ebc09c93789d5 (patch)
tree667a8d2abcc482aa9ae8deef1f7ed74aa3584ed3
parentBuild: Fix horribly slow compilation times (diff)
downloadefl-0ef41604e88b8a8224818824217ebc09c93789d5.tar.gz
Ecore: Use calloc() to initialize Ecore_Event_Key fully
Some fields (eg. data) may not be properly initialized. Use calloc() instead of malloc() will ensure proper initialization even if we add more fields. These fields (data) would even be passed down to Evas as Evas_Event_Key_Down for instance.
-rw-r--r--src/lib/ecore_drm/ecore_drm_evdev.c3
-rw-r--r--src/lib/ecore_psl1ght/ecore_psl1ght.c4
-rw-r--r--src/lib/ecore_sdl/ecore_sdl.c2
-rw-r--r--src/lib/ecore_wayland/ecore_wl_input.c2
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_events.c6
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_events.c5
-rw-r--r--src/modules/ecore_imf/wayland/wayland_imcontext.c2
7 files changed, 10 insertions, 14 deletions
diff --git a/src/lib/ecore_drm/ecore_drm_evdev.c b/src/lib/ecore_drm/ecore_drm_evdev.c
index a8383fa5c6..cbf58f3d4e 100644
--- a/src/lib/ecore_drm/ecore_drm_evdev.c
+++ b/src/lib/ecore_drm/ecore_drm_evdev.c
@@ -308,7 +308,7 @@ _device_handle_key(struct libinput_device *device, struct libinput_event_keyboar
if (!compose) compose = compose_buffer;
- e = malloc(sizeof(Ecore_Event_Key) + strlen(key) + strlen(keyname) +
+ e = calloc(1, sizeof(Ecore_Event_Key) + strlen(key) + strlen(keyname) +
((compose[0] != '\0') ? strlen(compose) : 0) + 3);
if (!e) return;
@@ -327,7 +327,6 @@ _device_handle_key(struct libinput_device *device, struct libinput_event_keyboar
e->timestamp = timestamp;
e->same_screen = 1;
e->keycode = code;
- e->data = NULL;
_device_modifiers_update(edev);
diff --git a/src/lib/ecore_psl1ght/ecore_psl1ght.c b/src/lib/ecore_psl1ght/ecore_psl1ght.c
index ad73f00502..e0f5580e69 100644
--- a/src/lib/ecore_psl1ght/ecore_psl1ght.c
+++ b/src/lib/ecore_psl1ght/ecore_psl1ght.c
@@ -351,7 +351,7 @@ _ecore_psl1ght_event_key(u16 key)
u16 utf16;
unsigned int i;
- ev = malloc(sizeof(Ecore_Event_Key));
+ ev = calloc(1, sizeof(Ecore_Event_Key));
if (!ev) return NULL;
ev->timestamp = _ecore_psl1ght_get_time ();
@@ -467,7 +467,7 @@ _ecore_psl1ght_pad_button (const char *name, int pressed)
{
Ecore_Event_Key *ev = NULL;
- ev = malloc(sizeof(Ecore_Event_Key));
+ ev = calloc(1, sizeof(Ecore_Event_Key));
if (!ev) return;
ev->timestamp = _ecore_psl1ght_get_time ();
diff --git a/src/lib/ecore_sdl/ecore_sdl.c b/src/lib/ecore_sdl/ecore_sdl.c
index 8b5897794b..ff026f5702 100644
--- a/src/lib/ecore_sdl/ecore_sdl.c
+++ b/src/lib/ecore_sdl/ecore_sdl.c
@@ -129,7 +129,7 @@ _ecore_sdl_event_key(SDL_Event *event, double timestamp)
Ecore_Event_Key *ev;
unsigned int i;
- ev = malloc(sizeof(Ecore_Event_Key));
+ ev = calloc(1, sizeof(Ecore_Event_Key));
if (!ev) return NULL;
ev->timestamp = timestamp;
diff --git a/src/lib/ecore_wayland/ecore_wl_input.c b/src/lib/ecore_wayland/ecore_wl_input.c
index d9f2fd3721..6a873e0a62 100644
--- a/src/lib/ecore_wayland/ecore_wl_input.c
+++ b/src/lib/ecore_wayland/ecore_wl_input.c
@@ -804,7 +804,7 @@ _ecore_wl_input_cb_keyboard_key(void *data, struct wl_keyboard *keyboard EINA_UN
_ecore_wl_input_keymap_translate_keysym(sym, input->modifiers,
compose, sizeof(compose));
- e = malloc(sizeof(Ecore_Event_Key) + strlen(key) + strlen(keyname) +
+ e = calloc(1, sizeof(Ecore_Event_Key) + strlen(key) + strlen(keyname) +
((compose[0] != '\0') ? strlen(compose) : 0) + 3);
if (!e) return;
diff --git a/src/lib/ecore_x/xcb/ecore_xcb_events.c b/src/lib/ecore_x/xcb/ecore_xcb_events.c
index e37b2aac67..0b71451e4b 100644
--- a/src/lib/ecore_x/xcb/ecore_xcb_events.c
+++ b/src/lib/ecore_x/xcb/ecore_xcb_events.c
@@ -2401,14 +2401,13 @@ _ecore_xcb_event_key_press(xcb_generic_event_t *event)
key = _ecore_xcb_keymap_keysym_to_string(sym);
if (!key) key = keyname;
- e = malloc(sizeof(Ecore_Event_Key) + strlen(key) + strlen(keyname) +
+ e = calloc(1, sizeof(Ecore_Event_Key) + strlen(key) + strlen(keyname) +
(compose ? strlen(compose) : 0) + 3);
if (e)
{
e->keyname = (char *)(e + 1);
e->key = e->keyname + strlen(keyname) + 1;
- e->compose = NULL;
if (compose) e->compose = (e->key + strlen(key) + 1);
e->string = e->compose;
@@ -2471,14 +2470,13 @@ _ecore_xcb_event_key_release(xcb_generic_event_t *event)
key = _ecore_xcb_keymap_keysym_to_string(sym);
if (!key) key = keyname;
- e = malloc(sizeof(Ecore_Event_Key) + strlen(key) + strlen(keyname) +
+ e = calloc(1, sizeof(Ecore_Event_Key) + strlen(key) + strlen(keyname) +
(compose ? strlen(compose) : 0) + 3);
if (e)
{
e->keyname = (char *)(e + 1);
e->key = e->keyname + strlen(keyname) + 1;
- e->compose = NULL;
if (compose) e->compose = (e->key + strlen(key) + 1);
e->string = e->compose;
diff --git a/src/lib/ecore_x/xlib/ecore_x_events.c b/src/lib/ecore_x/xlib/ecore_x_events.c
index e14efd7ce8..25d8fa21d6 100644
--- a/src/lib/ecore_x/xlib/ecore_x_events.c
+++ b/src/lib/ecore_x/xlib/ecore_x_events.c
@@ -366,9 +366,8 @@ _ecore_key_press(int event,
if (!key)
key = keyname;
- e =
- malloc(sizeof(Ecore_Event_Key) + strlen(key) + strlen(keyname) +
- (compose ? strlen(compose) : 0) + 3);
+ e = calloc(1, sizeof(Ecore_Event_Key) + strlen(key) + strlen(keyname) +
+ (compose ? strlen(compose) : 0) + 3);
if (!e)
goto on_error;
diff --git a/src/modules/ecore_imf/wayland/wayland_imcontext.c b/src/modules/ecore_imf/wayland/wayland_imcontext.c
index c324d1a536..4f2d982047 100644
--- a/src/modules/ecore_imf/wayland/wayland_imcontext.c
+++ b/src/modules/ecore_imf/wayland/wayland_imcontext.c
@@ -466,7 +466,7 @@ text_input_keysym(void *data,
"key event (key: %s)",
keyname);
- e = malloc(sizeof(Ecore_Event_Key) + strlen(key) + strlen(keyname) +
+ e = calloc(1, sizeof(Ecore_Event_Key) + strlen(key) + strlen(keyname) +
strlen(string) + 3);
if (!e) return;