diff options
Diffstat (limited to 'src/list.h')
-rw-r--r-- | src/list.h | 42 |
1 files changed, 16 insertions, 26 deletions
@@ -6,22 +6,18 @@ * * Simple lists in C * - * Authors: François-Régis Colin <fcolin@cena.fr> + * Authors: François-Régis Colin <fcolin@cena.dgac.fr> * * $Id$ * * Please refer to file version.h for the * copyright notice regarding this software */ -#ifdef WIN32 -#define TYPEOF(p) void* -#else -#if (__GNUC__ >= 2) +#if (__GNUC__ >= 3) #define TYPEOF(p) typeof (p) #else #define TYPEOF(p) void * #endif -#endif #define IVY_LIST_ITER( list, p, cond ) \ p = list; \ @@ -54,36 +50,30 @@ }\ } \ } - -#define IVY_LIST_ADD(list, p ) \ +/* +on place le code d'initialisation de l'objet entre START et END +pour eviter de chainer un objet non initialise +*/ +#define IVY_LIST_ADD_START(list, p ) \ if ((p = (TYPEOF(p)) (malloc( sizeof( *p ))))) \ { \ - memset( p, 0 , sizeof( *p ));\ - p->next = list; \ - list = p; \ - } + memset( p, 0 , sizeof( *p )); #define IVY_LIST_ADD_END(list, p ) \ - if ((p = (TYPEOF(p)) (malloc( sizeof( *p ))))) \ - { \ - TYPEOF(p) list_end; \ - memset( p, 0 , sizeof( *p ));\ - p->next = 0; \ - if ( list ) \ - {\ - list_end = list; \ - while ( list_end && list_end->next ) \ - list_end = list_end->next;\ - list_end->next = p; \ + p->next = list; \ + list = p; \ } \ - else list = p; \ + else \ + { \ + perror( "IVY LIST ADD malloc" ); \ + exit(0); \ } #define IVY_LIST_EACH( list, p ) \ for ( p = list ; p ; p = p -> next ) -#define IVY_LIST_EACH_SAFE( list, p, p_next )\ -for ( p = list ; (p_next = p ? p->next: p ),p ; p = p_next ) +#define IVY_LIST_EACH_SAFE( list, p, next )\ +for ( p = list ; (next = p ? p->next: p ),p ; p = next ) #define IVY_LIST_EMPTY( list ) \ { \ |