aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-03 14:51:43 +0100
committerMax Kellermann <max@duempel.org>2009-01-03 14:51:43 +0100
commit8ebb3196a854d7e870bbbe904b534641df7d5f89 (patch)
tree686ec9751d46b757e8b3b6db058cbde70cb9ff74 /src
parent30f75f7f01a2241fa8554ee1627e358a2cc8a3d0 (diff)
downloadmpd-8ebb3196a854d7e870bbbe904b534641df7d5f89.tar.gz
mpd-8ebb3196a854d7e870bbbe904b534641df7d5f89.tar.xz
mpd-8ebb3196a854d7e870bbbe904b534641df7d5f89.zip
listen: use GLib instead of utils.h
Diffstat (limited to '')
-rw-r--r--src/listen.c25
-rw-r--r--src/utils.c14
-rw-r--r--src/utils.h2
3 files changed, 21 insertions, 20 deletions
diff --git a/src/listen.c b/src/listen.c
index a45cb6d49..9f7577de1 100644
--- a/src/listen.c
+++ b/src/listen.c
@@ -26,6 +26,9 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stdlib.h>
#ifdef WIN32
#include <ws2tcpip.h>
@@ -89,8 +92,8 @@ static int establishListen(int pf, const struct sockaddr *addrp,
#endif
numberOfListenSockets++;
- listenSockets =
- xrealloc(listenSockets, sizeof(int) * numberOfListenSockets);
+ listenSockets = g_realloc(listenSockets, sizeof(listenSockets[0]) *
+ numberOfListenSockets);
listenSockets[numberOfListenSockets - 1] = sock;
@@ -102,6 +105,20 @@ static int establishListen(int pf, const struct sockaddr *addrp,
return 0;
}
+static bool ipv6Supported(void)
+{
+#ifdef HAVE_IPV6
+ int s;
+ s = socket(AF_INET6, SOCK_STREAM, 0);
+ if (s == -1)
+ return false;
+ close(s);
+ return true;
+#else
+ return false;
+#endif
+}
+
static void
parseListenConfigParam(G_GNUC_UNUSED unsigned int port, ConfigParam * param)
{
@@ -190,7 +207,7 @@ parseListenConfigParam(G_GNUC_UNUSED unsigned int port, ConfigParam * param)
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
- snprintf(service, sizeof(service), "%u", port);
+ g_snprintf(service, sizeof(service), "%u", port);
ret = getaddrinfo(param->value, service, &hints, &ai);
if (ret != 0)
@@ -262,7 +279,7 @@ void closeAllListenSockets(void)
}
numberOfListenSockets = 0;
- free(listenSockets);
+ g_free(listenSockets);
listenSockets = NULL;
}
diff --git a/src/utils.c b/src/utils.c
index 16a4cf018..4815a0bc1 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -61,20 +61,6 @@ void my_usleep(long usec)
#endif
}
-int ipv6Supported(void)
-{
-#ifdef HAVE_IPV6
- int s;
- s = socket(AF_INET6, SOCK_STREAM, 0);
- if (s == -1)
- return 0;
- close(s);
- return 1;
-#else
- return 0;
-#endif
-}
-
G_GNUC_MALLOC char *xstrdup(const char *s)
{
char *ret = strdup(s);
diff --git a/src/utils.h b/src/utils.h
index 4130eb74e..0e210cd5f 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -40,8 +40,6 @@ void stripReturnChar(char *string);
void my_usleep(long usec);
-int ipv6Supported(void);
-
/* trivial functions, keep them inlined */
static inline void xclose(int fd)
{