diff options
author | Max Kellermann <max@duempel.org> | 2013-10-15 22:18:37 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-10-15 22:47:46 +0200 |
commit | 12ab556477d8ffc620a84d29ac8abfaefeb4985f (patch) | |
tree | 189a4507770628f430484d92a8e7524c9fbdee57 /src/ClientRead.cxx | |
parent | 509f8dab8946cfc311def89f62352c0881e73348 (diff) | |
download | mpd-12ab556477d8ffc620a84d29ac8abfaefeb4985f.tar.gz mpd-12ab556477d8ffc620a84d29ac8abfaefeb4985f.tar.xz mpd-12ab556477d8ffc620a84d29ac8abfaefeb4985f.zip |
event/BufferedSocket: pass writable pointer to OnSocketInput()
Remove the const_cast from HttpdClient.cxx, and avoid one allocation
in ClientRead.cxx.
Diffstat (limited to 'src/ClientRead.cxx')
-rw-r--r-- | src/ClientRead.cxx | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/ClientRead.cxx b/src/ClientRead.cxx index 8f7c4cf7e..af2e572a2 100644 --- a/src/ClientRead.cxx +++ b/src/ClientRead.cxx @@ -22,27 +22,25 @@ #include "Main.hxx" #include "event/Loop.hxx" -#include <glib.h> - #include <assert.h> #include <string.h> BufferedSocket::InputResult -Client::OnSocketInput(const void *data, size_t length) +Client::OnSocketInput(void *data, size_t length) { - const char *p = (const char *)data; - const char *newline = (const char *)memchr(p, '\n', length); + char *p = (char *)data; + char *newline = (char *)memchr(p, '\n', length); if (newline == NULL) return InputResult::MORE; TimeoutMonitor::ScheduleSeconds(client_timeout); - char *line = g_strndup(p, newline - p); - BufferedSocket::ConsumeInput(newline + 1 - p); + /* terminate the string at the end of the line */ + *newline = 0; - enum command_return result = client_process_line(this, line); - g_free(line); + BufferedSocket::ConsumeInput(newline + 1 - p); + enum command_return result = client_process_line(this, p); switch (result) { case COMMAND_RETURN_OK: case COMMAND_RETURN_IDLE: |