tasn pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=09084220843a40c04bc633481ff483d7d4547675
commit 09084220843a40c04bc633481ff483d7d4547675 Author: Tom Hacohen <t...@stosb.com> Date: Thu Oct 15 12:04:05 2015 +0100 Eo callback call: Simplify callback desc matching code. As part of this change, we also error on adding invalid callbacks. --- src/lib/eo/eo_base_class.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/lib/eo/eo_base_class.c b/src/lib/eo/eo_base_class.c index 0801a9b..98809dd 100644 --- a/src/lib/eo/eo_base_class.c +++ b/src/lib/eo/eo_base_class.c @@ -561,7 +561,11 @@ _eo_base_event_callback_priority_add(Eo *obj, Eo_Base_Data *pd, Eo_Callback_Description *cb; cb = calloc(1, sizeof(*cb)); - if (!cb) return; + if (!cb || !desc || !func) + { + ERR("Tried adding callback with invalid values: cb: %p desc: %p func: %p\n", cb, desc, func); + return; + } cb->items.item.desc = desc; cb->items.item.func = func; cb->func_data = (void *) user_data; @@ -648,21 +652,13 @@ _eo_base_event_callback_array_del(Eo *obj, Eo_Base_Data *pd, static Eina_Bool _cb_desc_match(const Eo_Event_Description *a, const Eo_Event_Description *b) { - if (!a) - return EINA_FALSE; - - if (_legacy_event_desc_is(a) && _legacy_event_desc_is(b)) - { - return (a->name == b->name); - } - else if (_legacy_event_desc_is(a) || _legacy_event_desc_is(b)) + /* If one is legacy and the other is not, strcmp. Else, pointer compare. */ + if (EINA_UNLIKELY(_legacy_event_desc_is(a) != _legacy_event_desc_is(b))) { return !strcmp(a->name, b->name); } - else - { - return (a == b); - } + + return (a == b); } EOLIAN static Eina_Bool --