eo: make efl_replace work with a const pointer like efl_ref/unref do.
authorCedric BAIL <cedric@osg.samsung.com>
Fri, 16 Nov 2018 03:09:48 +0000 (12:09 +0900)
committerSangHyeon Jade Lee <sh10233.lee@samsung.com>
Tue, 20 Nov 2018 07:10:39 +0000 (16:10 +0900)
Summary: This is done to keep consistency with all the reference counting functions in Eo.

Reviewers: Hermet, smohanty

Reviewed By: Hermet

Subscribers: #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D7274

src/lib/eo/Eo.h

index 05c7cc5..19af94d 100644 (file)
@@ -2076,13 +2076,15 @@ EAPI int efl_callbacks_cmp(const Efl_Callback_Array_Item *a, const Efl_Callback_
  * @see efl_unref()
  */
 static inline Eina_Bool
-efl_replace(Eo **storage, Eo *new_obj)
+efl_replace(Eo **storage, const Eo *new_obj)
 {
+   Eo *tmp = NULL;
+
    EINA_SAFETY_ON_NULL_RETURN_VAL(storage, EINA_FALSE);
    if (*storage == new_obj) return EINA_FALSE;
-   if (new_obj) efl_ref(new_obj);
+   if (new_obj) tmp = efl_ref(new_obj);
    if (*storage) efl_unref(*storage);
-   *storage = new_obj;
+   *storage = tmp;
    return EINA_TRUE;
 }