Use calloc to initialize Ecore_Event_Mouse_XXX 57/66457/2
authorDuna Oh <duna.oh@samsung.com>
Tue, 19 Apr 2016 04:53:25 +0000 (13:53 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Tue, 19 Apr 2016 07:27:23 +0000 (00:27 -0700)
To make sure initialize all fields of Ecore_Event_Mouse_XXX,
use calloc() instead of malloc.

Signed-off-by: Duna Oh <duna.oh@samsung.com>
Change-Id: I32dfc796da60c7708477b365247df413217f9313

src/lib/ecore_cocoa/ecore_cocoa.m
src/lib/ecore_psl1ght/ecore_psl1ght.c
src/lib/ecore_sdl/ecore_sdl.c
src/lib/ecore_wayland/ecore_wl_input.c
src/lib/ecore_x/xcb/ecore_xcb_events.c
src/lib/ecore_x/xlib/ecore_x_events.c

index 568a828..0596c4e 100644 (file)
@@ -333,7 +333,7 @@ ecore_cocoa_feed_events(void *anEvent)
            Ecore_Event_Mouse_Wheel *ev;
            float dx, dy = 0;
 
-           ev = malloc(sizeof(Ecore_Event_Mouse_Wheel));
+           ev = calloc(1, sizeof(Ecore_Event_Mouse_Wheel));
            if (!ev) return pass;
 
            if ([event hasPreciseScrollingDeltas])
index 7f2e9ca..adc0595 100644 (file)
@@ -383,7 +383,7 @@ _ecore_psl1ght_mouse_move(s32 x_axis, s32 y_axis)
 {
    Ecore_Event_Mouse_Move *ev;
 
-   ev = malloc(sizeof(Ecore_Event_Mouse_Move));
+   ev = calloc(1, sizeof(Ecore_Event_Mouse_Move));
    if (!ev) return;
 
    mouse_x += x_axis;
@@ -416,7 +416,7 @@ _ecore_psl1ght_mouse_button(int button, int pressed)
    Ecore_Event_Mouse_Button *ev;
    static unsigned int previous_timestamp = 0;
 
-   ev = malloc(sizeof(Ecore_Event_Mouse_Button));
+   ev = calloc(1, sizeof(Ecore_Event_Mouse_Button));
    if (!ev) return;
 
    ev->window = 0;
@@ -449,7 +449,7 @@ _ecore_psl1ght_mouse_wheel(s8 wheel, s8 tilt)
 {
    Ecore_Event_Mouse_Wheel *ev;
 
-   ev = malloc(sizeof(Ecore_Event_Mouse_Wheel));
+   ev = calloc(1, sizeof(Ecore_Event_Mouse_Wheel));
    if (!ev) return;
 
    ev->timestamp = _ecore_psl1ght_get_time ();
index ff026f5..2fee26c 100644 (file)
@@ -167,7 +167,7 @@ ecore_sdl_feed_events(void)
           {
              Ecore_Event_Mouse_Move *ev;
 
-             ev = malloc(sizeof(Ecore_Event_Mouse_Move));
+             ev = calloc(1, sizeof(Ecore_Event_Mouse_Move));
              if (!ev) return;
 
              ev->timestamp = timestamp;
@@ -192,7 +192,7 @@ ecore_sdl_feed_events(void)
           {
              Ecore_Event_Mouse_Button *ev;
 
-             ev = malloc(sizeof(Ecore_Event_Mouse_Button));
+             ev = calloc(1, sizeof(Ecore_Event_Mouse_Button));
              if (!ev) return;
 
              ev->timestamp = timestamp;
@@ -216,7 +216,7 @@ ecore_sdl_feed_events(void)
           {
              Ecore_Event_Mouse_Wheel *ev;
 
-             ev = malloc(sizeof(Ecore_Event_Mouse_Wheel));
+             ev = calloc(1, sizeof(Ecore_Event_Mouse_Wheel));
              if (!ev) return;
 
              ev->timestamp = timestamp;
@@ -234,7 +234,7 @@ ecore_sdl_feed_events(void)
           {
              Ecore_Event_Mouse_Button *ev;
 
-             ev = malloc(sizeof(Ecore_Event_Mouse_Button));
+             ev = calloc(1, sizeof(Ecore_Event_Mouse_Button));
              if (!ev) return;
              ev->timestamp = timestamp;
              ev->window = event.button.windowID;
index cecc23c..f65d7fe 100644 (file)
@@ -1488,7 +1488,7 @@ _ecore_wl_input_mouse_move_send(Ecore_Wl_Input *input, Ecore_Wl_Window *win, uns
 
    /* LOGFN(__FILE__, __LINE__, __FUNCTION__); */
 
-   if (!(ev = malloc(sizeof(Ecore_Event_Mouse_Move)))) return;
+   if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Move)))) return;
 
    ev->timestamp = timestamp;
    ev->x = input->sx;
@@ -1618,7 +1618,7 @@ _ecore_wl_input_mouse_down_send(Ecore_Wl_Input *input, Ecore_Wl_Window *win, int
 
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
-   if (!(ev = malloc(sizeof(Ecore_Event_Mouse_Button)))) return;
+   if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Button)))) return;
 
    if (button == BTN_LEFT)
      ev->buttons = 1;
@@ -1741,7 +1741,7 @@ _ecore_wl_input_mouse_up_send(Ecore_Wl_Input *input, Ecore_Wl_Window *win, int d
 
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
-   if (!(ev = malloc(sizeof(Ecore_Event_Mouse_Button)))) return;
+   if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Button)))) return;
 
    if (button == BTN_LEFT)
      ev->buttons = 1;
@@ -1813,7 +1813,7 @@ _ecore_wl_input_mouse_wheel_send(Ecore_Wl_Input *input, unsigned int axis, int v
 
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
-   if (!(ev = malloc(sizeof(Ecore_Event_Mouse_Wheel)))) return;
+   if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Wheel)))) return;
 
    ev->timestamp = timestamp;
    ev->modifiers = input->modifiers;
index 9f1e2fc..0739d13 100644 (file)
@@ -609,7 +609,7 @@ _ecore_xcb_event_handle_button_press(xcb_generic_event_t *event)
      {
         Ecore_Event_Mouse_Wheel *e;
 
-        if (!(e = malloc(sizeof(Ecore_Event_Mouse_Wheel)))) return;
+        if (!(e = calloc(1, sizeof(Ecore_Event_Mouse_Wheel)))) return;
 
         e->timestamp = ev->time;
         e->modifiers = _ecore_xcb_events_modifiers_get(ev->state);
@@ -2523,7 +2523,7 @@ _ecore_xcb_event_mouse_move(uint16_t     timestamp,
 {
    Ecore_Event_Mouse_Move *e;
 
-   if (!(e = malloc(sizeof(Ecore_Event_Mouse_Move)))) return;
+   if (!(e = calloc(1, sizeof(Ecore_Event_Mouse_Move)))) return;
 
    e->window = win;
    e->root_window = root_win;
@@ -2596,7 +2596,7 @@ _ecore_xcb_event_mouse_button(int          event,
    Ecore_Event_Mouse_Button *e;
    Ecore_X_Mouse_Down_Info *info = NULL;
 
-   if (!(e = malloc(sizeof(Ecore_Event_Mouse_Button)))) return NULL;
+   if (!(e = calloc(1, sizeof(Ecore_Event_Mouse_Button)))) return NULL;
 
    e->window = win;
    e->root_window = root_win;
index a071d23..21ec829 100644 (file)
@@ -229,7 +229,7 @@ _ecore_mouse_move(unsigned int timestamp,
    Ecore_Event_Mouse_Move *e;
    Ecore_Event *event;
 
-   e = malloc(sizeof(Ecore_Event_Mouse_Move));
+   e = calloc(1, sizeof(Ecore_Event_Mouse_Move));
    if (!e)
      return;
 
@@ -290,7 +290,7 @@ _ecore_x_axis_update(Ecore_Window window,
    Ecore_Event_Axis_Update *e;
    int i;
 
-   e = malloc(sizeof(Ecore_Event_Axis_Update));
+   e = calloc(1, sizeof(Ecore_Event_Axis_Update));
    if (!e)
      {
         if (axis) free(axis);
@@ -428,7 +428,7 @@ _ecore_mouse_button(int event,
 {
    Ecore_Event_Mouse_Button *e;
 
-   e = malloc(sizeof(Ecore_Event_Mouse_Button));
+   e = calloc(1, sizeof(Ecore_Event_Mouse_Button));
    if (!e)
      return NULL;
 
@@ -596,7 +596,7 @@ _ecore_x_event_handle_button_press(XEvent *xevent)
      {
         Ecore_Event_Mouse_Wheel *e;
 
-        e = malloc(sizeof(Ecore_Event_Mouse_Wheel));
+        e = calloc(1, sizeof(Ecore_Event_Mouse_Wheel));
         if (!e)
           return;