Let valgrind help with EINA_MAGIC.

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".



SVN revision: 37961
This commit is contained in:
Gustavo Sverzut Barbieri 2008-12-06 06:53:14 +00:00
parent 5939d76d9c
commit 09924b54e5
7 changed files with 20 additions and 25 deletions

View File

@ -40,12 +40,12 @@ typedef void (*Eina_Accessor_Free_Callback)(Eina_Accessor *it);
struct _Eina_Accessor struct _Eina_Accessor
{ {
#define EINA_MAGIC_ACCESSOR 0x98761232
EINA_MAGIC;
Eina_Accessor_Get_At_Callback get_at; Eina_Accessor_Get_At_Callback get_at;
Eina_Accessor_Get_Container_Callback get_container; Eina_Accessor_Get_Container_Callback get_container;
Eina_Accessor_Free_Callback free; Eina_Accessor_Free_Callback free;
#define EINA_MAGIC_ACCESSOR 0x98761232
EINA_MAGIC;
}; };
#define FUNC_ACCESSOR_GET_AT(Function) ((Eina_Accessor_Get_At_Callback)Function) #define FUNC_ACCESSOR_GET_AT(Function) ((Eina_Accessor_Get_At_Callback)Function)

View File

@ -65,12 +65,12 @@ typedef void **Eina_Array_Iterator;
*/ */
struct _Eina_Array struct _Eina_Array
{ {
EINA_MAGIC;
void **data; /**< Pointer to a vector of pointer to payload */ void **data; /**< Pointer to a vector of pointer to payload */
unsigned int total; /**< Total number of slot in the vector */ unsigned int total; /**< Total number of slot in the vector */
unsigned int count; /**< Number of activ 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 */ unsigned int step; /**< How much must we grow the vector when it is full */
EINA_MAGIC;
}; };
EAPI int eina_array_init (void); EAPI int eina_array_init (void);

View File

@ -40,12 +40,12 @@ typedef void (*Eina_Iterator_Free_Callback)(Eina_Iterator *it);
struct _Eina_Iterator struct _Eina_Iterator
{ {
#define EINA_MAGIC_ITERATOR 0x98761233
EINA_MAGIC;
Eina_Iterator_Next_Callback next; Eina_Iterator_Next_Callback next;
Eina_Iterator_Get_Container_Callback get_container; Eina_Iterator_Get_Container_Callback get_container;
Eina_Iterator_Free_Callback free; Eina_Iterator_Free_Callback free;
#define EINA_MAGIC_ITERATOR 0x98761233
EINA_MAGIC;
}; };

View File

@ -60,20 +60,19 @@ typedef struct _Eina_List_Accounting Eina_List_Accounting;
*/ */
struct _Eina_List /** A linked list node */ struct _Eina_List /** A linked list node */
{ {
EINA_MAGIC;
void *data; /**< Pointer to list element payload */ void *data; /**< Pointer to list element payload */
Eina_List *next; /**< Next member in the list */ Eina_List *next; /**< Next member in the list */
Eina_List *prev; /**< Previous member in the list */ Eina_List *prev; /**< Previous member in the list */
struct _Eina_List_Accounting *accounting; /**< Private list accounting info - don't touch */ struct _Eina_List_Accounting *accounting; /**< Private list accounting info - don't touch */
EINA_MAGIC;
}; };
struct _Eina_List_Accounting struct _Eina_List_Accounting
{ {
EINA_MAGIC;
Eina_List *last; Eina_List *last;
unsigned int count; unsigned int count;
EINA_MAGIC;
}; };

View File

@ -72,20 +72,18 @@ struct _Eina_Iterator_Array
{ {
Eina_Iterator iterator; Eina_Iterator iterator;
EINA_MAGIC;
const Eina_Array *array; const Eina_Array *array;
unsigned int index; unsigned int index;
EINA_MAGIC;
}; };
typedef struct _Eina_Accessor_Array Eina_Accessor_Array; typedef struct _Eina_Accessor_Array Eina_Accessor_Array;
struct _Eina_Accessor_Array struct _Eina_Accessor_Array
{ {
Eina_Accessor accessor; Eina_Accessor accessor;
EINA_MAGIC;
const Eina_Array *array; const Eina_Array *array;
EINA_MAGIC;
}; };
static int _eina_array_init_count = 0; static int _eina_array_init_count = 0;

View File

@ -118,22 +118,22 @@ struct _Eina_Iterator_List
{ {
Eina_Iterator iterator; Eina_Iterator iterator;
EINA_MAGIC;
const Eina_List *head; const Eina_List *head;
const Eina_List *current; const Eina_List *current;
EINA_MAGIC;
}; };
struct _Eina_Accessor_List struct _Eina_Accessor_List
{ {
Eina_Accessor accessor; Eina_Accessor accessor;
EINA_MAGIC;
const Eina_List *head; const Eina_List *head;
const Eina_List *current; const Eina_List *current;
unsigned int index; unsigned int index;
EINA_MAGIC;
}; };
static int _eina_list_init_count = 0; static int _eina_list_init_count = 0;

View File

@ -42,22 +42,20 @@ typedef struct _Eina_Rectangle_Alloc Eina_Rectangle_Alloc;
struct _Eina_Rectangle_Pool struct _Eina_Rectangle_Pool
{ {
EINA_MAGIC;
Eina_Inlist *head; Eina_Inlist *head;
void *data; void *data;
unsigned int references; unsigned int references;
int w; int w;
int h; int h;
EINA_MAGIC;
}; };
struct _Eina_Rectangle_Alloc struct _Eina_Rectangle_Alloc
{ {
EINA_INLIST; EINA_INLIST;
EINA_MAGIC;
Eina_Rectangle_Pool *pool; Eina_Rectangle_Pool *pool;
EINA_MAGIC;
}; };
#define EINA_MAGIC_CHECK_RECTANGLE_POOL(d) \ #define EINA_MAGIC_CHECK_RECTANGLE_POOL(d) \