PUI_ani: free alloacted memory for event which is not added
[platform/core/uifw/libpui.git] / src / PUI_ani.c
index 28db340..325274e 100644 (file)
@@ -296,18 +296,7 @@ pui_ani_status_update(pui_ani_t *ani, pui_ani_status status)
 
        ani_h = ani->ani_h;
 
-       e = (PUI_Event_Animation_Status *)calloc(1, sizeof(PUI_Event_Animation_Status));
-
-       if (!e)
-       {
-               pui_err("Failed to allocate memory for PUI Event !\n");
-               return;
-       }
-
        ani->status = status;
-       e->ani_h = ani_h;
-       e->win = ecore_wl2_window_id_get(ani_h->pui_handle->win);
-       e->status = status;
 
        switch (status)
        {
@@ -337,6 +326,18 @@ pui_ani_status_update(pui_ani_t *ani, pui_ani_status status)
 
        if (ev_type > 0)
        {
+               e = (PUI_Event_Animation_Status *)calloc(1, sizeof(PUI_Event_Animation_Status));
+
+               if (!e)
+               {
+                       pui_err("Failed to allocate memory for PUI Event !\n");
+                       return;
+               }
+
+               e->ani_h = ani_h;
+               e->win = ecore_wl2_window_id_get(ani_h->pui_handle->win);
+               e->status = status;
+
                ecore_event_add(ev_type, e, NULL, ani_h);
        }
 }