[svn r227] More fixes on memory usage.
1.1 --- a/gmyth/src/gmyth_socket.c Tue Dec 19 16:25:25 2006 +0000
1.2 +++ b/gmyth/src/gmyth_socket.c Tue Dec 19 17:20:46 2006 +0000
1.3 @@ -112,28 +112,29 @@
1.4 static gint
1.5 gmyth_socket_toaddrinfo (const gchar *addr, gint port, struct addrinfo **addrInfo )
1.6 {
1.7 - struct addrinfo *hints;
1.8 + struct addrinfo hints;
1.9 gchar *portStr = NULL;
1.10 gint errorn = EADDRNOTAVAIL;
1.11
1.12 g_return_val_if_fail (addr != NULL, -1);
1.13
1.14 - hints = g_new0 (struct addrinfo, 1);
1.15 - hints->ai_family = AF_INET;
1.16 - hints->ai_socktype = SOCK_STREAM;
1.17 - /* hints->ai_flags = AI_NUMERICHOST; */
1.18 + /* hints = g_malloc0 ( sizeof(struct addrinfo) ); */
1.19 + memset ( &hints, 0, sizeof(struct addrinfo) );
1.20 + hints.ai_family = AF_INET;
1.21 + hints.ai_socktype = SOCK_STREAM;
1.22 + /* hints.ai_flags = AI_NUMERICHOST; */
1.23
1.24 if ( port != -1 )
1.25 portStr = g_strdup_printf ("%d", port);
1.26 else
1.27 portStr = NULL;
1.28
1.29 - gmyth_debug ("Address: %s, port: %s\n", addr, portStr);
1.30 - if ( ( errorn = getaddrinfo(addr, portStr, hints, addrInfo) ) != 0 ) {
1.31 + gmyth_debug ("Address: %s, port: %d\n", addr, port);
1.32 + if ( ( errorn = getaddrinfo(addr, portStr, &hints, addrInfo) ) != 0 ) {
1.33 g_printerr( "[%s] Socket ERROR: %s\n", __FUNCTION__, gai_strerror(errorn) );
1.34 }
1.35 g_free (portStr);
1.36 - g_free (hints);
1.37 + /* g_free (hints); */
1.38 return errorn;
1.39 }
1.40
1.41 @@ -162,8 +163,8 @@
1.42
1.43 GList *local_addrs = NULL;
1.44
1.45 - struct ifaddrs *ifaddr = g_new0( struct ifaddrs, 1 );
1.46 - struct ifaddrs *i = g_new0( struct ifaddrs, 1 );
1.47 + struct ifaddrs *ifaddr = g_malloc0( sizeof(struct ifaddrs) );
1.48 + struct ifaddrs *i = g_malloc0( sizeof(struct ifaddrs) );
1.49
1.50 gchar *addr = g_new0( gchar, NI_MAXHOST+1 );
1.51 gchar *ifname;
1.52 @@ -523,7 +524,7 @@
1.53
1.54 /* store hostname and port number */
1.55 if (gmyth_socket->hostname != NULL) {
1.56 - g_free (gmyth_socket->hostname);
1.57 + //g_free (gmyth_socket->hostname);
1.58 gmyth_socket->hostname = NULL;
1.59 }
1.60