aboutsummaryrefslogtreecommitdiffstats
path: root/src/ClientWrite.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-10-19 16:58:45 +0200
committerMax Kellermann <max@duempel.org>2013-10-19 17:24:21 +0200
commit5dc4cbdf82191bc29afc414ac10204bd17275d69 (patch)
tree76ad2e5c60de0e3f504a84cd1d6cff912153adbf /src/ClientWrite.cxx
parent1434e5a22e82b4176c24c536a91eefa183b78516 (diff)
downloadmpd-5dc4cbdf82191bc29afc414ac10204bd17275d69.tar.gz
mpd-5dc4cbdf82191bc29afc414ac10204bd17275d69.tar.xz
mpd-5dc4cbdf82191bc29afc414ac10204bd17275d69.zip
util/FormatString: new library to replace g_strdup_printf()
Diffstat (limited to 'src/ClientWrite.cxx')
-rw-r--r--src/ClientWrite.cxx35
1 files changed, 4 insertions, 31 deletions
diff --git a/src/ClientWrite.cxx b/src/ClientWrite.cxx
index ebed5f570..547f72bb5 100644
--- a/src/ClientWrite.cxx
+++ b/src/ClientWrite.cxx
@@ -19,11 +19,9 @@
#include "config.h"
#include "ClientInternal.hxx"
-
-#include <glib.h>
+#include "util/FormatString.hxx"
#include <string.h>
-#include <stdio.h>
/**
* Write a block of data to the client.
@@ -47,34 +45,9 @@ client_puts(Client *client, const char *s)
void
client_vprintf(Client *client, const char *fmt, va_list args)
{
-#ifndef WIN32
- va_list tmp;
- int length;
-
- va_copy(tmp, args);
- length = vsnprintf(NULL, 0, fmt, tmp);
- va_end(tmp);
-
- if (length <= 0)
- /* wtf.. */
- return;
-
- char *buffer = (char *)g_malloc(length + 1);
- vsnprintf(buffer, length + 1, fmt, args);
- client_write(client, buffer, length);
- g_free(buffer);
-#else
- /* On mingw32, snprintf() expects a 64 bit integer instead of
- a "long int" for "%li". This is not consistent with our
- expectation, so we're using plain sprintf() here, hoping
- the static buffer is large enough. Sorry for this hack,
- but WIN32 development is so painful, I'm not in the mood to
- do it properly now. */
-
- static char buffer[4096];
- vsprintf(buffer, fmt, args);
- client_write(client, buffer, strlen(buffer));
-#endif
+ char *p = FormatNewV(fmt, args);
+ client_write(client, p, strlen(p));
+ delete[] p;
}
void