# HG changeset patch # User rosfran # Date 1166548846 0 # Node ID 1c6e5a5dc5d251f56c0ca1b0dab09330e59d7f9d # Parent 332f87ba4017d7ea441ba18c4c2bfe56f16582a1 [svn r227] More fixes on memory usage. diff -r 332f87ba4017 -r 1c6e5a5dc5d2 gmyth/src/gmyth_socket.c --- a/gmyth/src/gmyth_socket.c Tue Dec 19 16:25:25 2006 +0000 +++ b/gmyth/src/gmyth_socket.c Tue Dec 19 17:20:46 2006 +0000 @@ -112,28 +112,29 @@ static gint gmyth_socket_toaddrinfo (const gchar *addr, gint port, struct addrinfo **addrInfo ) { - struct addrinfo *hints; + struct addrinfo hints; gchar *portStr = NULL; gint errorn = EADDRNOTAVAIL; g_return_val_if_fail (addr != NULL, -1); - hints = g_new0 (struct addrinfo, 1); - hints->ai_family = AF_INET; - hints->ai_socktype = SOCK_STREAM; - /* hints->ai_flags = AI_NUMERICHOST; */ + /* hints = g_malloc0 ( sizeof(struct addrinfo) ); */ + memset ( &hints, 0, sizeof(struct addrinfo) ); + hints.ai_family = AF_INET; + hints.ai_socktype = SOCK_STREAM; + /* hints.ai_flags = AI_NUMERICHOST; */ if ( port != -1 ) portStr = g_strdup_printf ("%d", port); else portStr = NULL; - gmyth_debug ("Address: %s, port: %s\n", addr, portStr); - if ( ( errorn = getaddrinfo(addr, portStr, hints, addrInfo) ) != 0 ) { + gmyth_debug ("Address: %s, port: %d\n", addr, port); + if ( ( errorn = getaddrinfo(addr, portStr, &hints, addrInfo) ) != 0 ) { g_printerr( "[%s] Socket ERROR: %s\n", __FUNCTION__, gai_strerror(errorn) ); } g_free (portStr); - g_free (hints); + /* g_free (hints); */ return errorn; } @@ -162,8 +163,8 @@ GList *local_addrs = NULL; - struct ifaddrs *ifaddr = g_new0( struct ifaddrs, 1 ); - struct ifaddrs *i = g_new0( struct ifaddrs, 1 ); + struct ifaddrs *ifaddr = g_malloc0( sizeof(struct ifaddrs) ); + struct ifaddrs *i = g_malloc0( sizeof(struct ifaddrs) ); gchar *addr = g_new0( gchar, NI_MAXHOST+1 ); gchar *ifname; @@ -523,7 +524,7 @@ /* store hostname and port number */ if (gmyth_socket->hostname != NULL) { - g_free (gmyth_socket->hostname); + //g_free (gmyth_socket->hostname); gmyth_socket->hostname = NULL; }