]> wirehaze git hosting - ppos.git/blobdiff - queue/queue.c

wirehaze git hosting

simplify queue_has()
[ppos.git] / queue / queue.c
index e54cb5e4730ae7da41d846e2f609ffef20a5577e..13c43b4045eaf6a10d3e54ff1ade6eb2add06f1f 100644 (file)
@@ -52,18 +52,14 @@ queue_destroy (struct queue_t *queue)
       return ERROR;
     }
 
       return ERROR;
     }
 
-  if (!(n = queue->head))
-    {
-      free (queue);
-      return NOERROR;
-    }
+  n = queue->head;
 
 
-  do
+  while (n)
     {
       next = n->next;
       node_destroy (n);
     {
       next = n->next;
       node_destroy (n);
+      n = next;
     }
     }
-  while ((n = next));
 
   free (queue);
   return NOERROR;
 
   free (queue);
   return NOERROR;
@@ -168,12 +164,7 @@ queue_has (struct queue_t *queue, void *item)
   while (n->item != item && (n = n->next))
     ;
 
   while (n->item != item && (n = n->next))
     ;
 
-  if (!n)
-    {
-      return false;
-    }
-
-  return true;
+  return n != NULL;
 }
 
 int
 }
 
 int