eo: fix callback cmp
authorMarcel Hollerbach <marcel-hollerbach@t-online.de>
Sat, 17 Sep 2016 13:17:25 +0000 (15:17 +0200)
committerMarcel Hollerbach <marcel-hollerbach@t-online.de>
Mon, 19 Sep 2016 11:25:23 +0000 (13:25 +0200)
Summary:
as told in _eina_stringshared_key_cmp in eina_hash.c:

originally we want to do this:
   return key1 - key2;
but since they are ptrs and an int can't store the different of 2 ptrs in
either 32 or 64bit (signed hasn't got enough range for the diff of 2
32bit values regardless of their type... we'd need 33bits or 65bits)

So changing this to the same logic.

Reviewers: tasn, raster

Subscribers: cedric, jpeg

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

src/lib/eo/eo.c

index 7aa36f4..a7dc3ce 100644 (file)
@@ -2154,5 +2154,7 @@ efl_manual_free(Eo *obj_id)
 EAPI int
 efl_callbacks_cmp(const Efl_Callback_Array_Item *a, const Efl_Callback_Array_Item *b)
 {
-   return (const unsigned char *) a->desc - (const unsigned char *) b->desc;
+   if (a->desc == b->desc) return 0;
+   else if (a->desc > b->desc) return 1;
+   else return -1;
 }