qqes modifs

This commit is contained in:
stormrider1982 2004-02-23 22:34:28 +00:00
parent 3502758445
commit a2f0764f4f
2 changed files with 12 additions and 1 deletions

View file

@ -19,6 +19,12 @@ int msgQueueElemAdd(msgQueue * queue, msgQueueElemId newElemId){
}
/* TODO: verifier si la liste n'est pas vide... */
if(queue->elemCounter < 1) {
NZG_ERROR("msgQueueAdd",queue->id);
goto ERROR;
}
/* on informe son prédecesseur qu'il a un suivant */
queueOldTailElem=msgQueueElemOpen(queue->tailId);
if (queueOldTailElem == NULL){
@ -32,6 +38,9 @@ int msgQueueElemAdd(msgQueue * queue, msgQueueElemId newElemId){
}
// on donne a la queue l'id du dernier element
strcpy(queue->tailId,newElemId);
// on incremente elemCounter
queue->elemCounter++;
ERROR:
return -1;

View file

@ -4,6 +4,7 @@ int msgQueueElemDelete(msgQueueElemId queueElemId){
msgQueueElem * queueElemAddr;
msgQueueElemId nextIdToDie;
queueElemAddr = msgQueueElemOpen(queueElemId);
strcpy(nextIdToDie,queueElemAddr->id);
msgQueueElemClose(queueElemAddr);
@ -13,12 +14,13 @@ int msgQueueElemDelete(msgQueueElemId queueElemId){
goto ERROR;
}
if (nextIdToDie != NULL){
if (nextIdToDie != queueElemId){
return msgQueueElemDelete(nextIdToDie);
} else {
return 0;
}
ERROR:
return -1;
}