]> code.delx.au - pulseaudio/blobdiff - polyp/queue.c
introduce pa_xmalloc() and friends
[pulseaudio] / polyp / queue.c
index 9befd4753ae4510b704d4f7ff36b0aa934e786ec..9488f43334dc6e9a5928da7dfe682407fb94708e 100644 (file)
@@ -27,6 +27,7 @@
 #include <stdlib.h>
 
 #include "queue.h"
+#include "xmalloc.h"
 
 struct queue_entry {
     struct queue_entry *next;
@@ -39,8 +40,7 @@ struct pa_queue {
 };
 
 struct pa_queue* pa_queue_new(void) {
-    struct pa_queue *q = malloc(sizeof(struct pa_queue));
-    assert(q);
+    struct pa_queue *q = pa_xmalloc(sizeof(struct pa_queue));
     q->front = q->back = NULL;
     q->length = 0;
     return q;
@@ -57,18 +57,17 @@ void pa_queue_free(struct pa_queue* q, void (*destroy)(void *p, void *userdata),
         if (destroy)
             destroy(e->data, userdata);
 
-        free(e);
+        pa_xfree(e);
         e = n;
     }
 
-    free(q);
+    pa_xfree(q);
 }
 
 void pa_queue_push(struct pa_queue *q, void *p) {
     struct queue_entry *e;
 
-    e = malloc(sizeof(struct queue_entry));
-
+    e = pa_xmalloc(sizeof(struct queue_entry));
     e->data = p;
     e->next = NULL;
 
@@ -96,7 +95,7 @@ void* pa_queue_pop(struct pa_queue *q) {
         q->back = NULL;
 
     p = e->data;
-    free(e);
+    pa_xfree(e);
 
     q->length--;