summaryrefslogtreecommitdiffstats
path: root/src/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2004-07-10 20:56:38 +0000
committerLennart Poettering <lennart@poettering.net>2004-07-10 20:56:38 +0000
commitc7bd759cdb2b8f16693750f89ed781707a53e5a9 (patch)
treed91b7d2e3dfd183adc4042d82c5aa61ba32c6ab2 /src/util.c
parent025389693d292b7a1c5f2c6e0ce96efa14062274 (diff)
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
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c30
1 files changed, 30 insertions, 0 deletions
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 <stdarg.h>
+#include <stdlib.h>
#include <signal.h>
#include <errno.h>
#include <assert.h>
@@ -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;
+ }
+}