From ca8501406a0f3708fe616d1eecdfcd8aebcb3af5 Mon Sep 17 00:00:00 2001 From: glenux Date: Mon, 23 Feb 2004 22:02:37 +0000 Subject: [PATCH] *** empty log message *** --- src/queueAdd.c | 2 +- src/queueRem.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 src/queueRem.c diff --git a/src/queueAdd.c b/src/queueAdd.c index 96d286c..781e33c 100644 --- a/src/queueAdd.c +++ b/src/queueAdd.c @@ -13,7 +13,7 @@ int msgQueueElemAdd(msgQueue * queue, msgQueueElemId newElemId){ goto ERROR; } strcpy(queueNewTailElem->next,newElemId); - if (msgQueueElemClose(queueNewTailElem)){ + if (msgQueueElemClose(queueNewTailElem) <0 ){ NZG_ERROR("msgQueueElemClose",newElemId); goto ERROR; } diff --git a/src/queueRem.c b/src/queueRem.c new file mode 100644 index 0000000..8cddbc4 --- /dev/null +++ b/src/queueRem.c @@ -0,0 +1,29 @@ +#include "libnazgul.h" + +// l'id de l'element enlevé vas dans oldElemId + +int msgQueueElemRem(msgQueue * queue, msgQueueElemId oldElemId){ + msgQueueElem * queueOldHeadElem; + + if (strcmp(queue->headId,queue->tailId)==0){ + NZG_ERROR("msgQueueElemRem : Empty queue",queue->id); + goto ERROR; + } + strcpy(oldElemId,queue->headId); + + queueOldHeadElem=msgQueueElemOpen(oldElemId); + if (queueOldHeadElem == NULL){ + NZG_ERROR("msgQueueElemOpen",oldElemId); + goto ERROR; + } + strcpy(queue->headId,queueOldHeadElem->next); + if (msgQueueElemClose(queueOldHeadElem)<0 ){ + NZG_ERROR("msgQueueElemClose",oldElemId); + goto ERROR; + + } + + return 0; +ERROR: + return -1; +}