- {
-#if debug > 1
- printf("purgequeue(): purge done (len=0)\n");
-#endif
- return 0;
- }
- /* One Node queue: free node and return */
- else if (sess->queue_outgoing->next == NULL)
- {
-#if debug > 1
- printf("purgequeue(): entered case len=1\n");
-#endif
- /* only free if sent AND unlocked -- dont assume sent structs are done */
- if ( (sess->queue_outgoing->lock == 0) &&
- (sess->queue_outgoing->sent == 1) )
- {
-#if debug > 1
- printf("purgequeue(): purging seqnum 0x%04x\n", sess->queue_outgoing->seqnum);
-#endif
- workingPtr2 = sess->queue_outgoing;
- sess->queue_outgoing = NULL;
- free(workingPtr2->data);
- free(workingPtr2);
- }
-#if debug > 1
- printf("purgequeue(): purge done (len=1)\n");
-#endif
- return 0;
- }
- else
- {
-#if debug > 1
- printf("purgequeue(): entering case len>1\n");
-#endif
- while(workingPtr->next != NULL)
- {
- if ( (workingPtr->next->lock == 0) &&
- (workingPtr->next->sent == 1) )
- {
-#if debug > 1
- printf("purgequeue(): purging seqnum 0x%04x\n", workingPtr->next->seqnum);
-#endif
- workingPtr2 = workingPtr->next;
- workingPtr->next = workingPtr2->next;
- free(workingPtr2->data);
- free(workingPtr2);
- }
- }
-#if debug > 1
- printf("purgequeue(): purge done (len>1)\n");
-#endif
- return 0;
+ return;
+
+ if (sess->queue_outgoing->next == NULL) {
+ if (!sess->queue_outgoing->lock && sess->queue_outgoing->sent) {
+ tmp = sess->queue_outgoing;
+ sess->queue_outgoing = NULL;
+ free(tmp->data);
+ free(tmp);