diff options
author | Max Kellermann <max@duempel.org> | 2008-09-18 01:00:12 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-09-18 01:00:12 +0200 |
commit | 7fff0ce33c1ebf8806827b6c5fb7dfb978ff5cc3 (patch) | |
tree | 09a69abedc03d6bd97c37e523b666b4b28c28f00 /src/libmpdclient.c | |
parent | a88a4249b0f8bc7977dc265fade64f8943b70a19 (diff) | |
download | mpd-7fff0ce33c1ebf8806827b6c5fb7dfb978ff5cc3.tar.gz mpd-7fff0ce33c1ebf8806827b6c5fb7dfb978ff5cc3.tar.xz mpd-7fff0ce33c1ebf8806827b6c5fb7dfb978ff5cc3.zip |
libmpdclient: don't strdup() MPD's welcome message
Why bother duplicating the buffer, when we can simply parse the
response directly from the input buffer?
Diffstat (limited to '')
-rw-r--r-- | src/libmpdclient.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/libmpdclient.c b/src/libmpdclient.c index 675521f3b..e63c20bbf 100644 --- a/src/libmpdclient.c +++ b/src/libmpdclient.c @@ -383,7 +383,6 @@ static int mpd_connect_un(mpd_Connection * connection, 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; } |