]> granicus.if.org Git - curl/commitdiff
Use the proper Curl_freeaddrinfo() for CURLRES_ARES.
authorGisle Vanem <gvanem@broadpark.no>
Mon, 24 Jul 2006 15:58:33 +0000 (15:58 +0000)
committerGisle Vanem <gvanem@broadpark.no>
Mon, 24 Jul 2006 15:58:33 +0000 (15:58 +0000)
lib/hostares.c
lib/hostip6.c

index af1513ca2d23e3a6be7198a6cff6611161aae103..1842d5f4ff4df72d01e5172e03f0d689576b6f44 100644 (file)
@@ -298,6 +298,22 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
  * The rest of this file is copied from hostip4.c. (needed for the
  * combination USE_ARES and ENABLE_IPV6).
  */
+/*
+ * This is a function for freeing name information in a protocol independent
+ * way.
+ */
+void Curl_freeaddrinfo(Curl_addrinfo *ai)
+{
+  Curl_addrinfo *next;
+
+  /* walk over the list and free all entries */
+  while(ai) {
+    next = ai->ai_next;
+    free(ai);
+    ai = next;
+  }
+}
+
 struct namebuf {
   struct hostent hostentry;
   char *h_addr_list[2];
index 7c17a15764073ec25ee41c8eb10c38e93b7d9e31..a1bc966c1299cbdb382b9347d4942a9613721d43 100644 (file)
@@ -88,6 +88,7 @@
  * Only for ipv6-enabled builds
  **********************************************************************/
 #ifdef CURLRES_IPV6
+#ifndef CURLRES_ARES
 /*
  * This is a wrapper function for freeing name information in a protocol
  * independent way. This takes care of using the appropriate underlaying
@@ -109,7 +110,8 @@ Curl_addrinfo *Curl_addrinfo_copy(const void *orig, int port)
   (void) port;
   return (Curl_addrinfo*)orig;
 }
-#endif
+#endif  /* CURLRES_ASYNCH */
+#endif  /* CURLRES_ARES */
 
 #ifdef CURLDEBUG
 /* These are strictly for memory tracing and are using the same style as the
@@ -136,6 +138,10 @@ int curl_dogetaddrinfo(const char *hostname, const char *service,
   return res;
 }
 
+/*
+ * For CURLRES_ARS, this should be written using ares_gethostbyaddr()
+ * (ignoring the fact c-ares doesn't return 'serv').
+ */
 #ifdef HAVE_GETNAMEINFO
 int curl_dogetnameinfo(GETNAMEINFO_QUAL_ARG1 GETNAMEINFO_TYPE_ARG1 sa,
                        GETNAMEINFO_TYPE_ARG2 salen,
@@ -171,8 +177,7 @@ void curl_dofreeaddrinfo(struct addrinfo *freethis,
     fprintf(logfile, "ADDR %s:%d freeaddrinfo(%p)\n",
             source, line, (void *)freethis);
 }
-
-#endif
+#endif  /* CURLDEBUG */
 
 /*
  * Curl_ipvalid() checks what CURL_IPRESOLVE_* requirements that might've
@@ -191,7 +196,7 @@ bool Curl_ipvalid(struct SessionHandle *data)
   return TRUE;
 }
 
-#if !defined(USE_THREADING_GETADDRINFO) && !defined(USE_ARES)
+#if !defined(USE_THREADING_GETADDRINFO) && !defined(CURLRES_ARES)
 
 #ifdef DEBUG_ADDRINFO
 static void dump_addrinfo(struct connectdata *conn, const struct addrinfo *ai)
@@ -296,6 +301,6 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
 
   return res;
 }
-#endif /* !USE_THREADING_GETADDRINFO && !USE_ARES */
+#endif /* !USE_THREADING_GETADDRINFO && !CURLRES_ARES */
 #endif /* ipv6 */