Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
Alter Hase
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 |
void destroyQueue(cw_Queue_t* pQueue){ assert(0 != pQueue); while(NULL != pQueue->pFrontNode){ i_Node_t* pTemp = pQueue->pFrontNode->pNextNode; free(pQueue->pFrontNode); pQueue->pFrontNode = pTemp; } pQueue->pRearNode = NULL; free(pQueue); } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
void destroyQueue(cw_Queue_t* pQueue){ assert(0 != pQueue); while(NULL != pQueue->pFrontNode){ if(NULL != pQueue->pFrontNode){ printf("W00T. Something is NULL!\n"); break; } i_Node_t* pTemp = pQueue->pFrontNode->pNextNode; free(pQueue->pFrontNode); pQueue->pFrontNode = pTemp; } pQueue->pRearNode = NULL; free(pQueue); } |
Alter Hase
Beruf: Softwareentwickler (aktuell Web/Node); Freiberuflicher Google Proxy
Alter Hase
Beim Eintritt in die Schleife.
Nutze den Debugger, der dürfte hier helfen.
C-/C++-Quelltext
1 2 3 4 5 6 7 8 9 while(NULL != pQueue->pFrontNode){ if(NULL != pQueue->pFrontNode){ // warum sollte die Bedingung nicht zutreffen, wenn sie gleich der while Schleife ist? //... } //... } }
Alter Hase
Das ist ja die Sache. Sie trifft nicht zu, obwohl die while Schleife zutrifft.
Alter Hase
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
void destroyQueue(cw_Queue_t* pQueue){ assert(0 != pQueue); while(NULL != pQueue->pFrontNode){ if(NULL == pQueue->pFrontNode) break; i_Node_t* pTemp = pQueue->pFrontNode->pNextNode; free(pQueue->pFrontNode); pQueue->pFrontNode = pTemp; } printf("Gotta out of here.\n"); pQueue->pRearNode = NULL; free(pQueue); } |
Alter Hase
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
#include <Util/Queue.h> #include <assert.h> #include <stdlib.h> //------------------------------------------------------------------------------ // IMPLEMENTATION DETAILS typedef struct i_Node{ void* pData; struct i_Node* pNextNode; } i_Node_t; struct cw_Queue{ i_Node_t* pFrontNode; i_Node_t* pRearNode; }; //------------------------------------------------------------------------------ // PUBLIC IMPLEMENTATION cw_Queue_t* createQueue(){ cw_Queue_t* pQueue = malloc(sizeof(cw_Queue_t)); pQueue->pFrontNode = NULL; pQueue->pRearNode = NULL; return pQueue; } void destroyQueue(cw_Queue_t* pQueue){ assert(0 != pQueue); while(NULL != pQueue->pFrontNode){ if(NULL == pQueue->pFrontNode){ break; } i_Node_t* pTemp = pQueue->pFrontNode->pNextNode; free(pQueue->pFrontNode); pQueue->pFrontNode = pTemp; } pQueue->pRearNode = NULL; free(pQueue); } void enqueue(cw_Queue_t* pQueue, void* pData){ assert(0 != pQueue); i_Node_t* pNode = malloc(sizeof(i_Node_t)); pNode->pData = pData; pNode->pNextNode = NULL; if((NULL == pQueue->pFrontNode) && (NULL == pQueue->pRearNode)){ pQueue->pFrontNode = pQueue->pRearNode = pNode; return; } pQueue->pRearNode->pNextNode = pNode; pQueue->pRearNode = pNode; } void* dequeue(cw_Queue_t* pQueue){ assert(0 != pQueue); if((NULL == pQueue->pFrontNode) && (NULL == pQueue->pRearNode)) return 0; if(pQueue->pFrontNode == pQueue->pRearNode){ void* pData = pQueue->pFrontNode->pData; free(pQueue->pFrontNode); pQueue->pFrontNode = pQueue->pRearNode = NULL; return pData; } i_Node_t* pTemp = pQueue->pFrontNode->pNextNode; pQueue->pFrontNode = pQueue->pFrontNode->pNextNode; void* pData = pTemp->pData; free(pTemp); return pData; } |
Alter Hase
Beruf: Softwareentwickler (aktuell Web/Node); Freiberuflicher Google Proxy
Ich muss gerade auf MinGW setzen und kenne mich mit GDB nicht aus.
Community-Fossil
Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer
Werbeanzeige