On Thu, 20 Aug 2009, Gustavo Sverzut Barbieri wrote:

I'd say it's good as is, if the other is fewer lines of code, then
better. But please cast to const char*  to avoid possible mistakes and
writing to that pointer.

that one is smaller:

Index: src/modules/mp/fixed_bitmap/eina_fixed_bitmap.c
===================================================================
--- src/modules/mp/fixed_bitmap/eina_fixed_bitmap.c     (revision 41856)
+++ src/modules/mp/fixed_bitmap/eina_fixed_bitmap.c     (working copy)
@@ -65,7 +65,7 @@
    void *a = &tmp.__rbtree;
    void *b = &tmp.__in_list;

-   return a - b;
+   return (char *)a - (char *)b;
 }

 static Eina_Rbtree_Direction
@@ -85,7 +85,7 @@
    int limit;

    limit = sizeof (Eina_Fixed_Bitmap_Pool) + mp->item_size * 32;
-   delta = a - b;
+   delta = (char *)a - (char *)b;

    if (delta > 0)
      return 1;
@@ -157,7 +157,7 @@
    if (pool->bitmask != 0xFFFFFFFF) push_front = EINA_TRUE;

    a = pool;
-   delta = (ptr - a - sizeof (Eina_Fixed_Bitmap_Pool)) / mp->item_size;
+ delta = ((char *)ptr - (char *)a - sizeof (Eina_Fixed_Bitmap_Pool)) / mp->item_size;

    assert(delta >= 0 && delta < 32);





On Thu, Aug 20, 2009 at 3:18 AM, Vincent Torri<[email protected]> wrote:

here is a patch. Another patch would be to cast when computing the
delta's. Which one do you prefer ?

Vincent

Index: eina_fixed_bitmap.c
===================================================================
--- eina_fixed_bitmap.c (revision 41856)
+++ eina_fixed_bitmap.c (working copy)
@@ -62,8 +62,8 @@
 _eina_rbtree_inlist_delta(void)
 {
    Eina_Fixed_Bitmap_Pool tmp;
-   void *a = &tmp.__rbtree;
-   void *b = &tmp.__in_list;
+   char *a = (char *)&tmp.__rbtree;
+   char *b = (char *)&tmp.__in_list;

    return a - b;
 }
@@ -79,8 +79,8 @@
 static int
 _eina_fixed_cmp_key(const Eina_Rbtree *node, const void *key, __UNUSED__
int length, Eina_Fixed_Bitmap *mp)
 {
-   const void *a = node;
-   const void *b = key;
+   char *a = (char *)node;
+   char *b = (char *)key;
    int delta;
    int limit;

@@ -146,7 +146,7 @@
 {
    Eina_Fixed_Bitmap *mp = data;
    Eina_Fixed_Bitmap_Pool *pool;
-   void *a;
+   char *a;
    Eina_Bool push_front = EINA_FALSE;
    int delta;

@@ -156,8 +156,8 @@
    if (!pool) return ;
    if (pool->bitmask != 0xFFFFFFFF) push_front = EINA_TRUE;

-   a = pool;
-   delta = (ptr - a - sizeof (Eina_Fixed_Bitmap_Pool)) / mp->item_size;
+   a = (char *)pool;
+   delta = ((char *)ptr - a - sizeof (Eina_Fixed_Bitmap_Pool)) /
mp->item_size;

    assert(delta >= 0 && delta < 32);




------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel




--
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--------------------------------------
MSN: [email protected]
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202

--
Ce message a ?t? v?rifi? par MailScanner
pour des virus ou des polluriels et rien de
suspect n'a ?t? trouv?.
Message d?livr? par le serveur de messagerie de l'Universit? d'Evry.


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to