seoz pushed a commit to branch master.

commit 7d4237cc7412d6a3b18c60a5843645ea257c6f38
Author: Daniel Juyung Seo <[email protected]>
Date:   Wed May 29 21:07:52 2013 +0900

    elm_store.c: ELM_SAFE_FREE adoption.
    
    I splited ELM_SAFE_FREE refactoring patches. One commit per each file as 
recommended.
    For the detail, please refer 3072dab12f12fe83fb5a628d15efd5cded11787f.
---
 src/lib/elm_store.c | 54 +++++++++--------------------------------------------
 1 file changed, 9 insertions(+), 45 deletions(-)

diff --git a/src/lib/elm_store.c b/src/lib/elm_store.c
index cbb8230..43d1d12 100644
--- a/src/lib/elm_store.c
+++ b/src/lib/elm_store.c
@@ -99,11 +99,7 @@ _store_cache_trim(Elm_Store *st)
         if (!sti->fetched)
           {
              eina_lock_release(&sti->lock);
-             if (sti->fetch_th)
-               {
-                  ecore_thread_cancel(sti->fetch_th);
-                  sti->fetch_th = NULL;
-               }
+             ELM_SAFE_FREE(sti->fetch_th, ecore_thread_cancel);
              eina_lock_take(&sti->lock);
           }
         sti->fetched = EINA_FALSE;
@@ -122,25 +118,13 @@ _store_genlist_del(void *data, Evas *e __UNUSED__, 
Evas_Object *obj __UNUSED__,
 {
    Elm_Store *st = data;
    st->genlist = NULL;
-   if (st->list_th)
-     {
-        ecore_thread_cancel(st->list_th);
-        st->list_th = NULL;
-     }
+   ELM_SAFE_FREE(st->list_th, ecore_thread_cancel);
    st->realized = eina_list_free(st->realized);
    while (st->items)
      {
         Elm_Store_Item *sti = (Elm_Store_Item *)st->items;
-        if (sti->eval_job)
-          {
-             ecore_job_del(sti->eval_job);
-             sti->eval_job = NULL;
-          }
-        if (sti->fetch_th)
-          {
-             ecore_thread_cancel(sti->fetch_th);
-             sti->fetch_th = NULL;
-          }
+        ELM_SAFE_FREE(sti->eval_job, ecore_job_del);
+        ELM_SAFE_FREE(sti->fetch_th, ecore_thread_cancel);
         if (sti->store->item.free) sti->store->item.free(sti);
         eina_lock_take(&sti->lock);
         if (sti->data)
@@ -234,11 +218,7 @@ _store_item_eval(void *data)
      }
    else
      {
-        if (sti->fetch_th)
-          {
-             ecore_thread_cancel(sti->fetch_th);
-             sti->fetch_th = NULL;
-          }
+        ELM_SAFE_FREE(sti->fetch_th, ecore_thread_cancel);
         _store_cache_trim(sti->store);
      }
 }
@@ -551,26 +531,14 @@ elm_store_free(Elm_Store *st)
 {
    void (*item_free)(Elm_Store_Item *);
    if (!EINA_MAGIC_CHECK(st, ELM_STORE_MAGIC)) return;
-   if (st->list_th)
-     {
-        ecore_thread_cancel(st->list_th);
-        st->list_th = NULL;
-     }
+   ELM_SAFE_FREE(st->list_th, ecore_thread_cancel);
    st->realized = eina_list_free(st->realized);
    item_free = st->item.free;
    while (st->items)
      {
         Elm_Store_Item *sti = (Elm_Store_Item *)st->items;
-        if (sti->eval_job)
-          {
-             ecore_job_del(sti->eval_job);
-             sti->eval_job = NULL;
-          }
-        if (sti->fetch_th)
-          {
-             ecore_thread_cancel(sti->fetch_th);
-             sti->fetch_th = NULL;
-          }
+        ELM_SAFE_FREE(sti->eval_job, ecore_job_del);
+        ELM_SAFE_FREE(sti->fetch_th, ecore_thread_cancel);
         if (item_free) item_free(sti);
         eina_lock_take(&sti->lock);
         if (sti->data)
@@ -622,11 +590,7 @@ elm_store_filesystem_directory_set(Elm_Store *store, const 
char *dir)
    Elm_Store_Filesystem *st = (Elm_Store_Filesystem *)store;
    if (!EINA_MAGIC_CHECK(store, ELM_STORE_MAGIC)) return;
    if (!EINA_MAGIC_CHECK(st, ELM_STORE_FILESYSTEM_MAGIC)) return;
-   if (store->list_th)
-     {
-        ecore_thread_cancel(store->list_th);
-        store->list_th = NULL;
-     }
+   ELM_SAFE_FREE(store->list_th, ecore_thread_cancel);
    if (!eina_stringshare_replace(&st->dir, dir)) return;
    store->list_th = ecore_thread_feedback_run(_store_filesystem_list_do,
                                               _store_filesystem_list_update,

-- 

------------------------------------------------------------------------------
Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap1

Reply via email to