From d831a0575c27a22fa1ee4524af4715842032eaa9 Mon Sep 17 00:00:00 2001 From: glenux Date: Wed, 25 Feb 2004 18:33:06 +0000 Subject: [PATCH] *** empty log message *** --- src/proto.h | 3 ++- src/spaceCreate.c | 11 +++++++++-- src/spaceListAdd.c | 9 ++++----- src/spaceListElemCreate.c | 4 +--- src/spaceListRem.c | 37 ++++++++++++++++++++++++++++++++++++- 5 files changed, 52 insertions(+), 12 deletions(-) diff --git a/src/proto.h b/src/proto.h index 3616938..a49cfef 100644 --- a/src/proto.h +++ b/src/proto.h @@ -93,7 +93,7 @@ int msgSpaceListClose(msgSpaceList *list); /* spaceListElemClose.c */ int msgSpaceListElemClose(msgSpaceListElem *listElem); /* spaceListElemCreate.c */ -int msgSpaceListElemCreate(msgSpaceListElemId elemenListId, msgSpace *space); +int msgSpaceListElemCreate(msgSpaceListElemId listElemId, msgSpace *space); /* spaceListElemLink.c */ /* spaceListElemOpen.c */ void *msgSpaceListElemOpen(msgSpaceListElemId listElemId); @@ -105,6 +105,7 @@ int msgSpaceListUnlock(void); /* spaceListOpen.c */ void *msgSpaceListOpen(void); /* spaceListRem.c */ +int msgSpaceListRem(msgSpaceListElemId oldElemId); /* spaceOpen.c */ msgSpace *msgSpaceOpen(msgSpaceId externId); /* state.c */ diff --git a/src/spaceCreate.c b/src/spaceCreate.c index e1f4fbc..1f6fc1c 100644 --- a/src/spaceCreate.c +++ b/src/spaceCreate.c @@ -131,6 +131,7 @@ msgSpace * msgSpaceCreate( } + /* on crée queueNb files de messages */ printf("Creating queues:\n"); for (i=0; inext,newElemId); if (msgSpaceListElemClose(listNewTailElem) <0 ){ - NZG_ERROR("msgQueueElemClose",newElemId); + NZG_ERROR("msgSpaceListElemClose",newElemId); goto ERROR; } - /* TODO: verifier si la liste n'est pas vide... */ + /* verifier si la liste n'est pas vide... */ if((strcmp(list->headId,list->id)==0) && (strcmp(list->tailId,list->id)==0)) { printf("- premier elem de queue -\n"); @@ -31,19 +31,18 @@ int msgSpaceListAdd(msgSpaceListElemId newElemId){ /* on informe son prédecesseur qu'il a un suivant */ listOldTailElem=msgSpaceListElemOpen(list->tailId); if (listOldTailElem == NULL){ - NZG_ERROR("msgQueueElemOpen",list->tailId); + NZG_ERROR("msgSpaceListElemOpen",list->tailId); goto ERROR; } strcpy(listOldTailElem->next,newElemId); if (msgSpaceListElemClose(listOldTailElem) < 0){ - NZG_ERROR("msgQueueElemClose",list->tailId); + NZG_ERROR("msgSpaceListElemClose",list->tailId); goto ERROR; } // on donne a la queue l'id du dernier element strcpy(list->tailId,newElemId); } // on incremente elemCounter - list->elemCounter++; msgSpaceListClose(list); return 0; ERROR: diff --git a/src/spaceListElemCreate.c b/src/spaceListElemCreate.c index 05d40f5..d7ed2bd 100644 --- a/src/spaceListElemCreate.c +++ b/src/spaceListElemCreate.c @@ -3,12 +3,10 @@ // cree un nouvel elemen int msgSpaceListElemCreate( - msgSpaceListElemId elemenListId, + msgSpaceListElemId listElemId, msgSpace * space) { - msgSpaceId listElemId; - strcpy(listElemId,space->id); int listElemFd; diff --git a/src/spaceListRem.c b/src/spaceListRem.c index 826fd8d..6e6dcc8 100644 --- a/src/spaceListRem.c +++ b/src/spaceListRem.c @@ -1,6 +1,41 @@ #include "libnazgul.h" +int msgSpaceListRem(msgSpaceListElemId oldElemId){ + msgSpaceListElem * listOldHeadElem; + msgSpaceList * list=NULL; -int msgSpaceListRem(msgSpaceListElemId spaceId); + list=msgSpaceListOpen(); + + + if (strcmp(list->headId,list->id)==0){ + NZG_ERROR("msgSpaceListElemRem : Empty list",list->id); + goto ERROR; + } + strcpy(oldElemId,list->headId); + + listOldHeadElem=msgSpaceListElemOpen(oldElemId); + if (listOldHeadElem == NULL){ + NZG_ERROR("msgSpaceListElemOpen",oldElemId); + goto ERROR; + } + + // on indique à la list le nouveau premier element + strcpy(list->headId,listOldHeadElem->next); + // on fait en sorte que l'element ne connaisse plus + // ses voisins (utile pour le Delete) + strcpy(listOldHeadElem->next,listOldHeadElem->id); + + if (msgSpaceListElemClose(listOldHeadElem)<0 ){ + NZG_ERROR("msgSpaceListElemClose",oldElemId); + goto ERROR; + + } + msgSpaceListClose(list); + + return 0; +ERROR: + return -1; + +}