]> code.delx.au - pulseaudio/blobdiff - src/pulsecore/memchunk.c
Remove unnecessary #includes
[pulseaudio] / src / pulsecore / memchunk.c
index 16a9c140195e353ccda05c037b2c0dcd214dc9d6..cc242e4e80a0c0472e4c6ca77d5ed17cbedd85a8 100644 (file)
@@ -1,5 +1,3 @@
-/* $Id$ */
-
 /***
   This file is part of PulseAudio.
 
@@ -30,7 +28,6 @@
 #include <string.h>
 #include <errno.h>
 
-#include <pulse/xmalloc.h>
 #include <pulsecore/macro.h>
 #include <pulsecore/core-util.h>
 
@@ -49,17 +46,20 @@ pa_memchunk* pa_memchunk_make_writable(pa_memchunk *c, size_t min) {
         pa_memblock_get_length(c->memblock) >= c->index+min)
         return c;
 
-    l = c->length;
-    if (l < min)
-        l = min;
+    l = PA_MAX(c->length, min);
 
     n = pa_memblock_new(pa_memblock_get_pool(c->memblock), l);
-    tdata = pa_memblock_acquire(n);
+
     sdata = pa_memblock_acquire(c->memblock);
+    tdata = pa_memblock_acquire(n);
+
     memcpy(tdata, (uint8_t*) sdata + c->index, c->length);
-    pa_memblock_release(n);
+
     pa_memblock_release(c->memblock);
+    pa_memblock_release(n);
+
     pa_memblock_unref(c->memblock);
+
     c->memblock = n;
     c->index = 0;
 
@@ -69,8 +69,7 @@ pa_memchunk* pa_memchunk_make_writable(pa_memchunk *c, size_t min) {
 pa_memchunk* pa_memchunk_reset(pa_memchunk *c) {
     pa_assert(c);
 
-    c->memblock = NULL;
-    c->length = c->index = 0;
+    memset(c, 0, sizeof(*c));
 
     return c;
 }
@@ -110,3 +109,12 @@ pa_memchunk* pa_memchunk_memcpy(pa_memchunk *dst, pa_memchunk *src) {
 
     return dst;
 }
+
+pa_bool_t pa_memchunk_isset(pa_memchunk *chunk) {
+    assert(chunk);
+
+    return
+        chunk->memblock ||
+        chunk->index > 0 ||
+        chunk->length > 0;
+}