Let valgrind help with EINA_MAGIC.
authorbarbieri <barbieri>
Sat, 6 Dec 2008 06:53:14 +0000 (06:53 +0000)
committerbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sat, 6 Dec 2008 06:53:14 +0000 (06:53 +0000)
Keep EINA_MAGIC at the end of the structure (WHEN POSSIBLE! Watch out
flexible arrays like char str[] at the end!)

this way if parts use EINA_MAGIC and others do not, it will possible overflow and valgrind can help us.

WARNING: make uninstall before update! Then make clean and make install, check if everything is working with "make check".

git-svn-id: http://svn.enlightenment.org/svn/e/trunk/eina@37961 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/include/eina_accessor.h
src/include/eina_array.h
src/include/eina_iterator.h
src/include/eina_list.h
src/lib/eina_array.c
src/lib/eina_list.c
src/lib/eina_rectangle.c

index e08555a..c4a265e 100644 (file)
@@ -40,12 +40,12 @@ typedef void (*Eina_Accessor_Free_Callback)(Eina_Accessor *it);
 
 struct _Eina_Accessor
 {
-#define EINA_MAGIC_ACCESSOR 0x98761232
-   EINA_MAGIC;
-
    Eina_Accessor_Get_At_Callback        get_at;
    Eina_Accessor_Get_Container_Callback        get_container;
    Eina_Accessor_Free_Callback          free;
+
+#define EINA_MAGIC_ACCESSOR 0x98761232
+   EINA_MAGIC;
 };
 
 #define FUNC_ACCESSOR_GET_AT(Function) ((Eina_Accessor_Get_At_Callback)Function)
index 1e9ed8c..2de8f47 100644 (file)
@@ -65,12 +65,12 @@ typedef void **Eina_Array_Iterator;
  */
 struct _Eina_Array
 {
-   EINA_MAGIC;
-
    void                **data;   /**< Pointer to a vector of pointer to payload */
    unsigned int   total;  /**< Total number of slot in the vector */
    unsigned int   count;  /**< Number of activ slot in the vector */
    unsigned int          step;   /**< How much must we grow the vector when it is full */
+
+   EINA_MAGIC;
 };
 
 EAPI int          eina_array_init     (void);
index 7b5bfb9..6aedb7f 100644 (file)
@@ -40,12 +40,12 @@ typedef void (*Eina_Iterator_Free_Callback)(Eina_Iterator *it);
 
 struct _Eina_Iterator
 {
-#define EINA_MAGIC_ITERATOR 0x98761233
-   EINA_MAGIC;
-
    Eina_Iterator_Next_Callback          next;
    Eina_Iterator_Get_Container_Callback get_container;
    Eina_Iterator_Free_Callback          free;
+
+#define EINA_MAGIC_ITERATOR 0x98761233
+   EINA_MAGIC;
 };
 
 
index c966171..520179d 100644 (file)
@@ -60,20 +60,19 @@ typedef struct _Eina_List_Accounting Eina_List_Accounting;
  */
 struct _Eina_List /** A linked list node */
 {
-   EINA_MAGIC;
-
    void      *data; /**< Pointer to list element payload */
    Eina_List *next; /**< Next member in the list */
    Eina_List *prev; /**< Previous member in the list */
    struct _Eina_List_Accounting *accounting; /**< Private list accounting info - don't touch */
+
+   EINA_MAGIC;
 };
 
 struct _Eina_List_Accounting
 {
-   EINA_MAGIC;
-
    Eina_List *last;
    unsigned int count;
+   EINA_MAGIC;
 };
 
 
index f99a996..5932ea9 100644 (file)
@@ -72,20 +72,18 @@ struct _Eina_Iterator_Array
 {
    Eina_Iterator iterator;
 
-   EINA_MAGIC;
-
    const Eina_Array *array;
    unsigned int index;
+
+   EINA_MAGIC;
 };
 
 typedef struct _Eina_Accessor_Array Eina_Accessor_Array;
 struct _Eina_Accessor_Array
 {
    Eina_Accessor accessor;
-
-   EINA_MAGIC;
-
    const Eina_Array *array;
+   EINA_MAGIC;
 };
 
 static int _eina_array_init_count = 0;
index 0b1c8bf..d82afed 100644 (file)
@@ -118,22 +118,22 @@ struct _Eina_Iterator_List
 {
    Eina_Iterator iterator;
 
-   EINA_MAGIC;
-
    const Eina_List *head;
    const Eina_List *current;
+
+   EINA_MAGIC;
 };
 
 struct _Eina_Accessor_List
 {
    Eina_Accessor accessor;
 
-   EINA_MAGIC;
-
    const Eina_List *head;
    const Eina_List *current;
 
    unsigned int index;
+
+   EINA_MAGIC;
 };
 
 static int _eina_list_init_count = 0;
index 62da094..16f490a 100644 (file)
@@ -42,22 +42,20 @@ typedef struct _Eina_Rectangle_Alloc Eina_Rectangle_Alloc;
 
 struct _Eina_Rectangle_Pool
 {
-   EINA_MAGIC;
-
    Eina_Inlist *head;
    void *data;
 
    unsigned int references;
    int w;
    int h;
+   EINA_MAGIC;
 };
 
 struct _Eina_Rectangle_Alloc
 {
    EINA_INLIST;
-   EINA_MAGIC;
-
    Eina_Rectangle_Pool *pool;
+   EINA_MAGIC;
 };
 
 #define EINA_MAGIC_CHECK_RECTANGLE_POOL(d)                    \