summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2015-10-15 12:04:05 +0100
committerTom Hacohen <tom@stosb.com>2015-10-19 10:22:41 +0100
commit4a90c1430a777ef96f0cbd71bd7578860feb39a6 (patch)
tree9ae341368e60003f1c46dbd4af4c9182fb9dcb5e /src
parentbe358369c16f111cbee18c0ce17d162953da2115 (diff)
Eo callback call: Simplify callback desc matching code.
As part of this change, we also error on adding invalid callbacks.
Diffstat (limited to 'src')
-rw-r--r--src/lib/eo/eo_base_class.c22
1 files 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,
561 Eo_Callback_Description *cb; 561 Eo_Callback_Description *cb;
562 562
563 cb = calloc(1, sizeof(*cb)); 563 cb = calloc(1, sizeof(*cb));
564 if (!cb) return; 564 if (!cb || !desc || !func)
565 {
566 ERR("Tried adding callback with invalid values: cb: %p desc: %p func: %p\n", cb, desc, func);
567 return;
568 }
565 cb->items.item.desc = desc; 569 cb->items.item.desc = desc;
566 cb->items.item.func = func; 570 cb->items.item.func = func;
567 cb->func_data = (void *) user_data; 571 cb->func_data = (void *) user_data;
@@ -648,21 +652,13 @@ _eo_base_event_callback_array_del(Eo *obj, Eo_Base_Data *pd,
648static Eina_Bool 652static Eina_Bool
649_cb_desc_match(const Eo_Event_Description *a, const Eo_Event_Description *b) 653_cb_desc_match(const Eo_Event_Description *a, const Eo_Event_Description *b)
650{ 654{
651 if (!a) 655 /* If one is legacy and the other is not, strcmp. Else, pointer compare. */
652 return EINA_FALSE; 656 if (EINA_UNLIKELY(_legacy_event_desc_is(a) != _legacy_event_desc_is(b)))
653
654 if (_legacy_event_desc_is(a) && _legacy_event_desc_is(b))
655 {
656 return (a->name == b->name);
657 }
658 else if (_legacy_event_desc_is(a) || _legacy_event_desc_is(b))
659 { 657 {
660 return !strcmp(a->name, b->name); 658 return !strcmp(a->name, b->name);
661 } 659 }
662 else 660
663 { 661 return (a == b);
664 return (a == b);
665 }
666} 662}
667 663
668EOLIAN static Eina_Bool 664EOLIAN static Eina_Bool