[vlc-commits] freeaddrinfo: rewrite as iterative

Rémi Denis-Courmont git at videolan.org
Wed Dec 3 12:15:15 CET 2014


vlc/vlc-2.2 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Dec  3 11:47:02 2014 +0900| [831d797977bc3e9fcd37e6203fbf8987a5ab61ba] | committer: Jean-Baptiste Kempf

freeaddrinfo: rewrite as iterative

(cherry picked from commit 4716a65fc63c00a3970f65848ce3d94809d22ef0)
Signed-off-by: KO Myung-Hun <komh at chollian.net>
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.2.git/?a=commit;h=831d797977bc3e9fcd37e6203fbf8987a5ab61ba
---

 compat/freeaddrinfo.c |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/compat/freeaddrinfo.c b/compat/freeaddrinfo.c
index 0d5a1d8..fecc3fa 100644
--- a/compat/freeaddrinfo.c
+++ b/compat/freeaddrinfo.c
@@ -34,12 +34,13 @@
  */
 void freeaddrinfo (struct addrinfo *res)
 {
-    if (res == NULL)
-        return;
+    while (res != NULL)
+    {
+        struct addrinfo *next = res->ai_next;
 
-    freeaddrinfo (res->ai_next);
-
-    free (res->ai_canonname);
-    free (res->ai_addr);
-    free (res);
+        free (res->ai_canonname);
+        free (res->ai_addr);
+        free (res);
+        res = next;
+    }
 }



More information about the vlc-commits mailing list