summaryrefslogtreecommitdiff
path: root/ares_init.c
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2012-01-19 20:20:56 +0100
committerYang Tse <yangsita@gmail.com>2012-01-19 20:20:56 +0100
commit4ab65461b6aefd0654a5b586bc6ee57976f3fba3 (patch)
treeb566773d0190ee88302227cb96e01db18854a2bc /ares_init.c
parentf1a1df1e6c4fed8dc5816f6e09a0cfeed64bb71f (diff)
downloadc-ares-4ab65461b6aefd0654a5b586bc6ee57976f3fba3.tar.gz
c-ares-4ab65461b6aefd0654a5b586bc6ee57976f3fba3.tar.bz2
c-ares-4ab65461b6aefd0654a5b586bc6ee57976f3fba3.zip
ares_init.c: fix compiler warning on winsock builds
Diffstat (limited to 'ares_init.c')
-rw-r--r--ares_init.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/ares_init.c b/ares_init.c
index 0c1d545..d18f97e 100644
--- a/ares_init.c
+++ b/ares_init.c
@@ -1,6 +1,6 @@
/* Copyright 1998 by the Massachusetts Institute of Technology.
- * Copyright (C) 2007-2011 by Daniel Stenberg
+ * Copyright (C) 2007-2012 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
@@ -1186,11 +1186,14 @@ static int init_by_defaults(ares_channel channel)
/* Derive a default domain search list from the kernel hostname,
* or set it to empty if the hostname isn't helpful.
*/
+#ifndef HAVE_GETHOSTNAME
+ channel->ndomains = 0; /* default to none */
+#else
+ GETHOSTNAME_TYPE_ARG2 lenv = 64;
size_t len = 64;
int res;
channel->ndomains = 0; /* default to none */
-#ifdef HAVE_GETHOSTNAME
hostname = malloc(len);
if(!hostname) {
rc = ARES_ENOMEM;
@@ -1198,11 +1201,12 @@ static int init_by_defaults(ares_channel channel)
}
do {
- res = gethostname(hostname, len);
+ res = gethostname(hostname, lenv);
if(toolong(res)) {
char *p;
len *= 2;
+ lenv *= 2;
p = realloc(hostname, len);
if(!p) {
rc = ARES_ENOMEM;