diff options
author | TingPing <tingping@tingping.se> | 2014-12-28 06:37:25 -0500 |
---|---|---|
committer | TingPing <tingping@tingping.se> | 2014-12-28 06:44:44 -0500 |
commit | 83032b1aa3c3e5910c5cfd3e0ea1d25827f56475 (patch) | |
tree | 9be32a04d3070eac82177e11d182dad40a63baa7 /src/common/identd.c | |
parent | c4cb1b25ec06a5b0cb718c6f8e74630df9a9bc64 (diff) |
Use glib for all allocations
- Removes need to check for malloc failure - Removes need for NULL checks on free - Adds checks for integer overflows - Removes some extra memset calls - Removes chance of mixing libc and glib malloc/free
Diffstat (limited to 'src/common/identd.c')
-rw-r--r-- | src/common/identd.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/common/identd.c b/src/common/identd.c index c4050929..cbe6ff5e 100644 --- a/src/common/identd.c +++ b/src/common/identd.c @@ -42,7 +42,7 @@ identd (char *username) sok = socket (AF_INET, SOCK_STREAM, 0); if (sok == INVALID_SOCKET) { - free (username); + g_free (username); return 0; } @@ -56,14 +56,14 @@ identd (char *username) if (bind (sok, (struct sockaddr *) &addr, sizeof (addr)) == SOCKET_ERROR) { closesocket (sok); - free (username); + g_free (username); return 0; } if (listen (sok, 1) == SOCKET_ERROR) { closesocket (sok); - free (username); + g_free (username); return 0; } @@ -72,7 +72,7 @@ identd (char *username) closesocket (sok); if (read_sok == INVALID_SOCKET) { - free (username); + g_free (username); return 0; } @@ -99,7 +99,7 @@ identd (char *username) sleep (1); closesocket (read_sok); - free (username); + g_free (username); return 0; } @@ -118,7 +118,7 @@ identd_ipv6 (char *username) sok = socket (AF_INET6, SOCK_STREAM, 0); if (sok == INVALID_SOCKET) { - free (username); + g_free (username); return 0; } @@ -132,14 +132,14 @@ identd_ipv6 (char *username) if (bind (sok, (struct sockaddr *) &addr, sizeof (addr)) == SOCKET_ERROR) { closesocket (sok); - free (username); + g_free (username); return 0; } if (listen (sok, 1) == SOCKET_ERROR) { closesocket (sok); - free (username); + g_free (username); return 0; } @@ -148,7 +148,7 @@ identd_ipv6 (char *username) closesocket (sok); if (read_sok == INVALID_SOCKET) { - free (username); + g_free (username); return 0; } @@ -171,7 +171,7 @@ identd_ipv6 (char *username) sleep (1); closesocket (read_sok); - free (username); + g_free (username); return 0; } @@ -188,7 +188,7 @@ identd_start (char *username) { identd_ipv6_is_running = TRUE; CloseHandle (CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE) identd_ipv6, - strdup (username), 0, &tidv6)); + g_strdup (username), 0, &tidv6)); } #endif @@ -196,6 +196,6 @@ identd_start (char *username) { identd_is_running = TRUE; CloseHandle (CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE) identd, - strdup (username), 0, &tid)); + g_strdup (username), 0, &tid)); } } |