[pulseaudio-commits] r1531 - in /branches/lennart/src/pulsecore: core-util.c core-util.h

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Wed Jul 25 08:49:36 PDT 2007


Author: lennart
Date: Wed Jul 25 17:49:35 2007
New Revision: 1531

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=3D1531&root=3Dpulseaudio&vi=
ew=3Drev
Log:
add our own implementation for pa_snprintf() because NUL termination is app=
arently not guaranteed on windows and a couple of other libcs

Modified:
    branches/lennart/src/pulsecore/core-util.c
    branches/lennart/src/pulsecore/core-util.h

Modified: branches/lennart/src/pulsecore/core-util.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/=
core-util.c?rev=3D1531&root=3Dpulseaudio&r1=3D1530&r2=3D1531&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/pulsecore/core-util.c (original)
+++ branches/lennart/src/pulsecore/core-util.c Wed Jul 25 17:49:35 2007
@@ -31,7 +31,6 @@
 #include <stdlib.h>
 #include <signal.h>
 #include <errno.h>
-#include <assert.h>
 #include <string.h>
 #include <stdio.h>
 #include <fcntl.h>
@@ -83,6 +82,7 @@
 #include <pulsecore/core-error.h>
 #include <pulsecore/winsock.h>
 #include <pulsecore/log.h>
+#include <pulsecore/macro.h>
 =

 #include "core-util.h"
 =

@@ -1202,3 +1202,21 @@
 =

     return 0;
 }
+
+/* Same as snprintf, but guarantees NUL-termination on every platform */
+int pa_snprintf(char *str, size_t size, const char *format, ...) {
+    int ret;
+    va_list ap;
+
+    pa_assert(str);
+    pa_assert(size > 0);
+    pa_assert(format);
+    =

+    va_start(ap, format);
+    ret =3D vsnprintf(str, size, format, ap);
+    va_end(ap);
+
+    str[size-1] =3D 0;
+
+    return ret;
+}

Modified: branches/lennart/src/pulsecore/core-util.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/=
core-util.h?rev=3D1531&root=3Dpulseaudio&r1=3D1530&r2=3D1531&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/pulsecore/core-util.h (original)
+++ branches/lennart/src/pulsecore/core-util.h Wed Jul 25 17:49:35 2007
@@ -92,4 +92,6 @@
 int pa_atoi(const char *s, int32_t *ret_i);
 int pa_atou(const char *s, uint32_t *ret_u);
 =

+int pa_snprintf(char *str, size_t size, const char *format, ...);
+
 #endif




More information about the pulseaudio-commits mailing list