From fccce0894722dd5e08c42650123601bf62da8e16 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 16 Nov 2018 12:09:48 +0900 Subject: [PATCH] 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 --- src/lib/eo/Eo.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 05c7cc5286..19af94db41 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -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; }