From 8731d0b4ae61e37c81187c779da7e2a7b8327d8c Mon Sep 17 00:00:00 2001 From: rivka_zan Date: Thu, 19 Feb 2004 20:44:22 +0000 Subject: [PATCH] *Liste chaine avec maloc --- src/nzg_msgList.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/nzg_msgList.c diff --git a/src/nzg_msgList.c b/src/nzg_msgList.c new file mode 100644 index 0000000..6efc170 --- /dev/null +++ b/src/nzg_msgList.c @@ -0,0 +1,43 @@ +#include +#include + +typedef struct MsgSpaceListElem msgSpaceListElem; + +struct MsgSpaceListElem{ + void *id; + int ownerpid; //valeur du pid que lon stoke dan la liste + msgSpaceListElem *next; //adresse du prochain elemen de la liste + +}; + +/* ajout dans la liste */ + +msgSpaceListElem *addBegining( msgSpaceListElem*list,int ownerpid){ + msgSpaceListElem *unSpacemsgListElem; + if( (unSpacemsgListElem=(msgSpaceListElem *)malloc(sizeof(msgSpaceListElem) ) )==NULL){ + perror("ereur dallocation de memoire"); + exit(1);} + unSpacemsgListElem->ownerpid = ownerpid; + return(unSpacemsgListElem); + +} + + + + + +int main(int argc,char **argv){ + msgSpaceListElem *ma_liste; + msgSpaceListElem *listMove; + ma_liste=NULL; + ma_liste=addBegining(ma_liste, 3); + ma_liste=addBegining(ma_liste, 6); + ma_liste=addBegining(ma_liste, 5); + for (listMove=ma_liste ;listMove!=NULL ; listMove=listMove->next) + { + printf("valaeur :%d\n",listMove->ownerpid); + } + return(0); +} + +