commit 0168b19a39bc20180d72bf21dd5b22c096244dee Author: David Goulet dgoulet@ev0ke.net Date: Wed Aug 7 08:10:37 2013 -0400
Remove unused code
Signed-off-by: David Goulet dgoulet@ev0ke.net --- src/lib/gethostbyname.c | 92 ----------------------------------------------- 1 file changed, 92 deletions(-)
diff --git a/src/lib/gethostbyname.c b/src/lib/gethostbyname.c index 87dace1..3e3588e 100644 --- a/src/lib/gethostbyname.c +++ b/src/lib/gethostbyname.c @@ -26,98 +26,6 @@ #include "torsocks.h"
/* - * Free the given hostent structure and all pointers contained inside. - */ -static void free_hostent(struct hostent *he) -{ - if (!he) { - return; - } - - if (he->h_name) { - free(he->h_name); - } - - if (he->h_aliases) { - int i = 0; - - while (he->h_aliases[i] != NULL) { - free(he->h_aliases[i]); - i++; - } - } - - if (he->h_addr_list) { - int i = 0; - - while (he->h_addr_list[i] != NULL) { - free(he->h_addr_list[i]); - i++; - } - } - - free(he); -} - -/* - * Allocate a hostent structure with the given type. - * - * On error, return NULL. - */ -static struct hostent *alloc_hostent(int af) -{ - void *addr = NULL; - char **addr_list = NULL, **aliases = NULL; - struct hostent *he = NULL; - size_t addrlen; - - if (af != AF_INET && af != AF_INET6) { - goto error; - } - - he = zmalloc(sizeof(*he)); - addr_list = zmalloc(sizeof(*addr_list) * 2); - aliases = zmalloc(sizeof(*aliases)); - if (!he || !addr_list || !aliases) { - PERROR("zmalloc hostent"); - goto error; - } - - switch (af) { - case AF_INET: - addr = zmalloc(sizeof(struct in_addr)); - addrlen = sizeof(struct in_addr); - break; - case AF_INET6: - addr = zmalloc(sizeof(struct in6_addr)); - addrlen = sizeof(struct in6_addr); - break; - default: - assert(0); - goto error; - } - if (!addr) { - PERROR("zmalloc addr"); - goto error; - } - - he->h_name = NULL; - he->h_addr_list = addr_list; - he->h_addr_list[0] = addr; - he->h_addr_list[1] = NULL; - he->h_aliases = aliases; - he->h_aliases[0] = NULL; - he->h_length = addrlen; - he->h_addrtype = af; - - return he; - -error: - free_hostent(he); - return NULL; -} - -/* * Torsocks call for gethostbyname(3). * * NOTE: This call is OBSOLETE in the glibc.