qqes modifs

This commit is contained in:
stormrider1982 2004-02-23 22:34:28 +00:00 committed by Glenn Y. Rolland
parent 97b36b686f
commit 776800c730
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){
@ -33,6 +39,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;
}