tasn pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=d6ac2464bb8146c0b360adbad8a26f920a7b0394

commit d6ac2464bb8146c0b360adbad8a26f920a7b0394
Author: Tom Hacohen <[email protected]>
Date:   Tue Nov 26 12:10:53 2013 +0000

    Eo: Make eo_manual_free() return a success flag.
    
    eo_manual_free() can fail in some cases, and it is useful for users of
    this API to know about it in order to decide what to do.
---
 src/lib/eo/Eo.h                      |  3 ++-
 src/lib/eo/eo.c                      |  8 +++++---
 src/tests/eo/suite/eo_test_general.c | 14 +++++++-------
 3 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h
index 228872f..9ae740c 100644
--- a/src/lib/eo/Eo.h
+++ b/src/lib/eo/Eo.h
@@ -910,10 +910,11 @@ EAPI void eo_manual_free_set(Eo *obj, Eina_Bool 
manual_free);
  * eo_manual_free_set has been called before with the parameter EINA_TRUE.
  * An error will be printed if this function is called when the manual
  * free option is not set to EINA_TRUE or the number of refs is not 0.
+ * @return EINA_TRUE if successfully freed. EINA_FALSE otherwise.
  *
  * @see eo_manual_free_set()
  */
-EAPI void eo_manual_free(Eo *obj);
+EAPI Eina_Bool eo_manual_free(Eo *obj);
 
 /**
  * @brief Checks if the object was already descructed (only relevant for 
manual_free objects).
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index bc4cd8a..b677393 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -1531,7 +1531,7 @@ eo_manual_free_set(Eo *obj_id, Eina_Bool manual_free)
    obj->manual_free = manual_free;
 }
 
-EAPI void
+EAPI Eina_Bool
 eo_manual_free(Eo *obj_id)
 {
    EO_OBJ_POINTER_RETURN(obj_id, obj);
@@ -1539,15 +1539,17 @@ eo_manual_free(Eo *obj_id)
    if (EINA_FALSE == obj->manual_free)
      {
         ERR("Tried to manually free the object %p while the option has not 
been set; see eo_manual_free_set for more information.", obj);
-        return;
+        return EINA_FALSE;
      }
 
    if (!obj->del)
      {
         ERR("Tried deleting the object %p while still referenced(%d).", 
obj_id, obj->refcount);
-        return;
+        return EINA_FALSE;
      }
 
    _eo_free(obj);
+
+   return EINA_TRUE;
 }
 
diff --git a/src/tests/eo/suite/eo_test_general.c 
b/src/tests/eo/suite/eo_test_general.c
index 900ec58..35f7879 100644
--- a/src/tests/eo/suite/eo_test_general.c
+++ b/src/tests/eo/suite/eo_test_general.c
@@ -304,7 +304,7 @@ START_TEST(eo_man_free)
 
    obj = eo_add(klass, NULL);
    fail_if(!obj);
-   eo_manual_free(obj);
+   fail_if(eo_manual_free(obj));
    eo_unref(obj);
 
    _man_should_des = EINA_FALSE;
@@ -314,17 +314,17 @@ START_TEST(eo_man_free)
 
    obj = eo_add(klass, NULL);
    fail_if(!obj);
-   eo_manual_free(obj);
+   fail_if(eo_manual_free(obj));
    fail_if(eo_destructed_is(obj));
    eo_unref(obj);
    fail_if(!eo_destructed_is(obj));
-   eo_manual_free(obj);
+   fail_if(!eo_manual_free(obj));
 
    obj = eo_add(klass, NULL);
    fail_if(!obj);
    eo_unref(obj);
    fail_if(!eo_destructed_is(obj));
-   eo_manual_free(obj);
+   fail_if(!eo_manual_free(obj));
 
    _man_should_con = EINA_FALSE;
    klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL);
@@ -333,7 +333,7 @@ START_TEST(eo_man_free)
 
    obj = eo_add(klass, NULL);
    fail_if(!obj);
-   eo_manual_free(obj);
+   fail_if(eo_manual_free(obj));
    eo_unref(obj);
 
    obj = eo_add(klass, NULL);
@@ -343,7 +343,7 @@ START_TEST(eo_man_free)
    eo_ref(obj);
    eo_unref(obj);
    eo_unref(obj);
-   eo_manual_free(obj);
+   fail_if(!eo_manual_free(obj));
 
    obj = eo_add(klass, NULL);
    fail_if(!obj);
@@ -354,7 +354,7 @@ START_TEST(eo_man_free)
    eo_unref(obj);
    eo_unref(obj);
    eo_unref(obj);
-   eo_manual_free(obj);
+   fail_if(!eo_manual_free(obj));
 
    eo_shutdown();
 }

-- 


Reply via email to