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
This commit is contained in:
Lennart Poettering 2004-08-04 16:39:30 +00:00
parent 24291aff27
commit 46091a9237
61 changed files with 700 additions and 631 deletions

View file

@ -29,6 +29,7 @@
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <xmalloc.h>
#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);