aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2011-11-27 20:05:57 +0100
committerMax Kellermann <max@duempel.org>2011-11-27 20:17:52 +0100
commit07067f8b958d52699526f4f757bca2714da183f4 (patch)
tree578353208f6c88482a3348858720515c48a30f9f /src
parenta1e824ada0a08c0065a8a85a2e2aa979f6e97121 (diff)
downloadmpd-07067f8b958d52699526f4f757bca2714da183f4.tar.gz
mpd-07067f8b958d52699526f4f757bca2714da183f4.tar.xz
mpd-07067f8b958d52699526f4f757bca2714da183f4.zip
pcm_buffer: add assertions
Diffstat (limited to 'src')
-rw-r--r--src/pcm_buffer.c4
-rw-r--r--src/pcm_buffer.h6
2 files changed, 10 insertions, 0 deletions
diff --git a/src/pcm_buffer.c b/src/pcm_buffer.c
index 75b76a5d3..b0449d44e 100644
--- a/src/pcm_buffer.c
+++ b/src/pcm_buffer.c
@@ -32,6 +32,8 @@ align_8k(size_t size)
void *
pcm_buffer_get(struct pcm_buffer *buffer, size_t size)
{
+ assert(buffer != NULL);
+
if (buffer->size < size) {
/* free the old buffer */
g_free(buffer->buffer);
@@ -40,5 +42,7 @@ pcm_buffer_get(struct pcm_buffer *buffer, size_t size)
buffer->buffer = g_malloc(buffer->size);
}
+ assert(buffer->size >= size);
+
return buffer->buffer;
}
diff --git a/src/pcm_buffer.h b/src/pcm_buffer.h
index b1c597407..fe223c742 100644
--- a/src/pcm_buffer.h
+++ b/src/pcm_buffer.h
@@ -22,6 +22,8 @@
#include <glib.h>
+#include <assert.h>
+
/**
* Manager for a temporary buffer which grows as needed. We could
* allocate a new buffer every time pcm_convert() is called, but that
@@ -39,6 +41,8 @@ struct pcm_buffer {
static inline void
pcm_buffer_init(struct pcm_buffer *buffer)
{
+ assert(buffer != NULL);
+
buffer->buffer = NULL;
buffer->size = 0;
}
@@ -49,6 +53,8 @@ pcm_buffer_init(struct pcm_buffer *buffer)
static inline void
pcm_buffer_deinit(struct pcm_buffer *buffer)
{
+ assert(buffer != NULL);
+
g_free(buffer->buffer);
buffer->buffer = NULL;