diff options
author | Max Kellermann <max@duempel.org> | 2013-12-04 08:43:55 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-12-04 08:43:55 +0100 |
commit | e1901e97c2f3f6901ca7bac31a68ac9da1e3a4ee (patch) | |
tree | fac9794063e63a6e3e870a6455f13df54ef146fe /src/ClientNew.cxx | |
parent | d694150372408cd80b89a2e27a88f91b5f856b67 (diff) | |
download | mpd-e1901e97c2f3f6901ca7bac31a68ac9da1e3a4ee.tar.gz mpd-e1901e97c2f3f6901ca7bac31a68ac9da1e3a4ee.tar.xz mpd-e1901e97c2f3f6901ca7bac31a68ac9da1e3a4ee.zip |
system/Resolver: sockaddr_to_string() returns std::string()
No GLib memory allocation.
Diffstat (limited to '')
-rw-r--r-- | src/ClientNew.cxx | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/src/ClientNew.cxx b/src/ClientNew.cxx index 1bcc2f4d3..5618e9ece 100644 --- a/src/ClientNew.cxx +++ b/src/ClientNew.cxx @@ -28,8 +28,6 @@ #include "util/Error.hxx" #include "Log.hxx" -#include <glib.h> - #include <assert.h> #ifdef WIN32 #include <winsock2.h> @@ -63,15 +61,12 @@ client_new(EventLoop &loop, Partition &partition, int fd, const struct sockaddr *sa, size_t sa_length, int uid) { static unsigned int next_client_num; - char *remote; + const auto remote = sockaddr_to_string(sa, sa_length); assert(fd >= 0); #ifdef HAVE_LIBWRAP if (sa->sa_family != AF_UNIX) { - char *hostaddr = sockaddr_to_string(sa, sa_length, - IgnoreError()); - // TODO: shall we obtain the program name from argv[0]? const char *progname = "mpd"; @@ -84,14 +79,11 @@ client_new(EventLoop &loop, Partition &partition, /* tcp wrappers says no */ FormatWarning(client_domain, "libwrap refused connection (libwrap=%s) from %s", - progname, hostaddr); + progname, remote.c_str()); - g_free(hostaddr); close_socket(fd); return; } - - g_free(hostaddr); } #endif /* HAVE_WRAP */ @@ -109,9 +101,8 @@ client_new(EventLoop &loop, Partition &partition, client_list.Add(*client); - remote = sockaddr_to_string(sa, sa_length, IgnoreError()); - FormatInfo(client_domain, "[%u] opened from %s", client->num, remote); - g_free(remote); + FormatInfo(client_domain, "[%u] opened from %s", + client->num, remote.c_str()); } void |