From c7bd759cdb2b8f16693750f89ed781707a53e5a9 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 10 Jul 2004 20:56:38 +0000 Subject: add description field for sinks/sources add owner field to all entities add client file to source outputs and sink inputs git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@59 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/util.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/util.c') diff --git a/src/util.c b/src/util.c index 6fe4bbee..aceb772d 100644 --- a/src/util.c +++ b/src/util.c @@ -1,3 +1,5 @@ +#include +#include #include #include #include @@ -230,3 +232,31 @@ void pa_check_for_sigpipe(void) { if (sa.sa_handler == SIG_DFL) fprintf(stderr, "polypaudio: WARNING: SIGPIPE is not trapped. This might cause malfunction!\n"); } + +/* The following is based on an example from the GNU libc documentation */ +char *pa_sprintf_malloc(const char *format, ...) { + int size = 100; + char *c = NULL; + + assert(format); + + for(;;) { + int r; + va_list ap; + + c = realloc(c, size); + assert(c); + + va_start(ap, format); + r = vsnprintf(c, size, format, ap); + va_end(ap); + + if (r > -1 && r < size) + return c; + + if (r > -1) /* glibc 2.1 */ + size = r+1; + else /* glibc 2.0 */ + size *= 2; + } +} -- cgit