[vlc-devel] freeaddrinfo: rewrite as iterative
KO Myung-Hun
komh78 at gmail.com
Sat Nov 22 10:32:17 CET 2014
Hi/2.
Rémi Denis-Courmont wrote:
> vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Nov 22 11:20:24 2014 +0200| [4716a65fc63c00a3970f65848ce3d94809d22ef0] | committer: Rémi Denis-Courmont
>
> freeaddrinfo: rewrite as iterative
>
>> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4716a65fc63c00a3970f65848ce3d94809d22ef0
> ---
>
> 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;
> + }
> }
Just out of curiosity. Any special reasons to have to use a while loop
instead of a recursive loop ?
--
KO Myung-Hun
Using Mozilla SeaMonkey 2.7.2
Under OS/2 Warp 4 for Korean with FixPak #15
In VirtualBox v4.1.32 on Intel Core i7-3615QM 2.30GHz with 8GB RAM
Korean OS/2 User Community : http://www.ecomstation.co.kr
More information about the vlc-devel
mailing list