aboutsummaryrefslogtreecommitdiffstats
path: root/src/output
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-10-15 22:18:37 +0200
committerMax Kellermann <max@duempel.org>2013-10-15 22:47:46 +0200
commit12ab556477d8ffc620a84d29ac8abfaefeb4985f (patch)
tree189a4507770628f430484d92a8e7524c9fbdee57 /src/output
parent509f8dab8946cfc311def89f62352c0881e73348 (diff)
downloadmpd-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/output')
-rw-r--r--src/output/HttpdClient.cxx11
-rw-r--r--src/output/HttpdClient.hxx3
2 files changed, 6 insertions, 8 deletions
diff --git a/src/output/HttpdClient.cxx b/src/output/HttpdClient.cxx
index 5b65cc956..c622f823a 100644
--- a/src/output/HttpdClient.cxx
+++ b/src/output/HttpdClient.cxx
@@ -402,7 +402,7 @@ HttpdClient::OnSocketReady(unsigned flags)
}
BufferedSocket::InputResult
-HttpdClient::OnSocketInput(const void *data, size_t length)
+HttpdClient::OnSocketInput(void *data, size_t length)
{
if (state == RESPONSE) {
LogWarning(httpd_output_domain,
@@ -411,8 +411,8 @@ HttpdClient::OnSocketInput(const void *data, size_t length)
return InputResult::CLOSED;
}
- const char *line = (const char *)data;
- const char *newline = (const char *)memchr(line, '\n', length);
+ char *line = (char *)data;
+ char *newline = (char *)memchr(line, '\n', length);
if (newline == nullptr)
return InputResult::MORE;
@@ -421,9 +421,8 @@ HttpdClient::OnSocketInput(const void *data, size_t length)
if (newline > line && newline[-1] == '\r')
--newline;
- /* terminate the string at the end of the line; the const_cast
- is a dirty hack */
- *const_cast<char *>(newline) = 0;
+ /* terminate the string at the end of the line */
+ *newline = 0;
if (!HandleLine(line)) {
assert(state == RESPONSE);
diff --git a/src/output/HttpdClient.hxx b/src/output/HttpdClient.hxx
index d481898a2..90295fdf7 100644
--- a/src/output/HttpdClient.hxx
+++ b/src/output/HttpdClient.hxx
@@ -177,8 +177,7 @@ public:
protected:
virtual bool OnSocketReady(unsigned flags) override;
- virtual InputResult OnSocketInput(const void *data,
- size_t length) override;
+ virtual InputResult OnSocketInput(void *data, size_t length) override;
virtual void OnSocketError(Error &&error) override;
virtual void OnSocketClosed() override;
};