summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjestin2000-01-14 15:13:48 +0000
committerjestin2000-01-14 15:13:48 +0000
commit02e638eb51cfdf5156cb465771d7fbccec01066e (patch)
tree0c0d373f00345f9bf51ae8b2c3f49cf5b0ec4f73 /src
parentf8e2714d49c86685c3d2a1b7b164d6d8a791f5ca (diff)
downloadivy-c-02e638eb51cfdf5156cb465771d7fbccec01066e.zip
ivy-c-02e638eb51cfdf5156cb465771d7fbccec01066e.tar.gz
ivy-c-02e638eb51cfdf5156cb465771d7fbccec01066e.tar.bz2
ivy-c-02e638eb51cfdf5156cb465771d7fbccec01066e.tar.xz
Bon, je le remet, on m'a expliqué pourquoi c'est pas super d'enlever list.h.
A suivre ?
Diffstat (limited to 'src')
-rw-r--r--src/list.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/list.h b/src/list.h
new file mode 100644
index 0000000..4a6fe26
--- /dev/null
+++ b/src/list.h
@@ -0,0 +1,55 @@
+#define LIST_ITER( list, p, cond ) \
+ p = list; \
+ while ( p && (cond) ) p = p->next
+
+#define LIST_REMOVE( list, p ) \
+ { \
+ void *toRemove; \
+ if ( list == p ) \
+ { \
+ list = p->next; \
+ free(p);\
+ } \
+ else \
+ {\
+ toRemove = p;\
+ LIST_ITER( list, p, ( p->next != toRemove ));\
+ if ( p )\
+ {\
+ /* somme tricky swapping to use a untyped variable */\
+ void *suiv; \
+ void *prec = p;\
+ p = toRemove;\
+ suiv = p->next;\
+ p = prec;\
+ p->next = suiv;\
+ free(toRemove);\
+ }\
+ } \
+ }
+
+#define LIST_ADD(list, p ) \
+ if ((p = malloc( sizeof( *p ))))\
+ { \
+ memset( p, 0 , sizeof( *p ));\
+ p->next = list; \
+ list = p; \
+ }
+
+#define LIST_EACH( list, p ) \
+ for ( p = list ; p ; p = p -> next )
+
+#define LIST_EACH_SAFE( list, p, next )\
+for ( p = list ; (next = p ? p->next: p ),p ; p = next )
+
+
+#define LIST_EMPTY( list ) \
+ { \
+ void *p; \
+ while( list ) \
+ { \
+ p = list;\
+ list = list->next; \
+ free(p);\
+ } \
+ }