From 46091a9237f17f4295dca7140d8d70b4fce8b357 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 4 Aug 2004 16:39:30 +0000 Subject: introduce pa_xmalloc() and friends implement module auto loading git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@103 fefdeb5f-60dc-0310-8127-8f9354f1896f --- polyp/strbuf.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'polyp/strbuf.c') diff --git a/polyp/strbuf.c b/polyp/strbuf.c index c6a3772d..169604e8 100644 --- a/polyp/strbuf.c +++ b/polyp/strbuf.c @@ -29,6 +29,7 @@ #include #include #include +#include #include "strbuf.h" @@ -44,8 +45,7 @@ struct pa_strbuf { }; struct pa_strbuf *pa_strbuf_new(void) { - struct pa_strbuf *sb = malloc(sizeof(struct pa_strbuf)); - assert(sb); + struct pa_strbuf *sb = pa_xmalloc(sizeof(struct pa_strbuf)); sb->length = 0; sb->head = sb->tail = NULL; return sb; @@ -56,10 +56,10 @@ void pa_strbuf_free(struct pa_strbuf *sb) { while (sb->head) { struct chunk *c = sb->head; sb->head = sb->head->next; - free(c); + pa_xfree(c); } - free(sb); + pa_xfree(sb); } char *pa_strbuf_tostring(struct pa_strbuf *sb) { @@ -67,8 +67,7 @@ char *pa_strbuf_tostring(struct pa_strbuf *sb) { struct chunk *c; assert(sb); - t = malloc(sb->length+1); - assert(t); + t = pa_xmalloc(sb->length+1); e = t; for (c = sb->head; c; c = c->next) { @@ -101,8 +100,7 @@ void pa_strbuf_putsn(struct pa_strbuf *sb, const char *t, size_t l) { if (!l) return; - c = malloc(sizeof(struct chunk)+l); - assert(c); + c = pa_xmalloc(sizeof(struct chunk)+l); c->next = NULL; c->length = l; @@ -131,8 +129,7 @@ int pa_strbuf_printf(struct pa_strbuf *sb, const char *format, ...) { for(;;) { va_list ap; - c = realloc(c, sizeof(struct chunk)+size); - assert(c); + c = pa_xrealloc(c, sizeof(struct chunk)+size); va_start(ap, format); r = vsnprintf(c->text, size, format, ap); -- cgit