summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a88a424)
raw | patch | inline | side by side (parent: a88a424)
author | Max Kellermann <max@duempel.org> | |
Wed, 17 Sep 2008 23:00:12 +0000 (01:00 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Wed, 17 Sep 2008 23:00:12 +0000 (01:00 +0200) |
Why bother duplicating the buffer, when we can simply parse the
response directly from the input buffer?
response directly from the input buffer?
src/libmpdclient.c | patch | blob | history |
diff --git a/src/libmpdclient.c b/src/libmpdclient.c
index 675521f3b67592bd8621f8ab5d7126846dd00b42..e63c20bbf673c5aa3eb2950bbc5ba4f4ce3ffe5a 100644 (file)
--- a/src/libmpdclient.c
+++ b/src/libmpdclient.c
mpd_Connection * mpd_newConnection(const char * host, int port, float timeout) {
int err;
char * rt;
- char * output = NULL;
mpd_Connection * connection = malloc(sizeof(mpd_Connection));
struct timeval tv;
fd_set fds;
@@ -452,14 +451,11 @@ mpd_Connection * mpd_newConnection(const char * host, int port, float timeout) {
}
*rt = '\0';
- output = strdup(connection->buffer);
- strcpy(connection->buffer,rt+1);
- connection->buflen = strlen(connection->buffer);
-
- if(mpd_parseWelcome(connection,host,port,output) == 0)
+ if (mpd_parseWelcome(connection, host, port, connection->buffer) == 0)
connection->doneProcessing = 1;
- free(output);
+ strcpy(connection->buffer,rt+1);
+ connection->buflen = strlen(connection->buffer);
return connection;
}