eo: make efl_replace work with a const pointer like efl_ref/unref do.

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
This commit is contained in:
Cedric BAIL 2018-11-16 12:09:48 +09:00 committed by Hermet Park
parent 2dd9dbff60
commit fccce08947
1 changed files with 5 additions and 3 deletions

View 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;
}