]> git.sesse.net Git - vlc/blob - compat/freeaddrinfo.c
dvdnav: add Demux submodule
[vlc] / compat / freeaddrinfo.c
1 /*****************************************************************************
2  * freeaddrinfo.c: freeaddrinfo() replacement functions
3  *****************************************************************************
4  * Copyright (C) 2005 the VideoLAN team
5  * Copyright (C) 2002-2007 Rémi Denis-Courmont
6  * Copyright (C) 2011-2014 KO Myung-Hun
7  *
8  * Authors: KO Myung-Hun <komh@chollian.net>
9  *          Rémi Denis-Courmont <rem # videolan.org>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License as published by
13  * the Free Software Foundation; either version 2.1 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24  *****************************************************************************/
25
26 #ifdef HAVE_CONFIG_H
27 # include "config.h"
28 #endif
29
30 #include <stdlib.h>
31
32 /*
33  * This function must be used to free the memory allocated by getaddrinfo().
34  */
35 void freeaddrinfo (struct addrinfo *res)
36 {
37     while (res != NULL)
38     {
39         struct addrinfo *next = res->ai_next;
40
41         free (res->ai_canonname);
42         free (res->ai_addr);
43         free (res);
44         res = next;
45     }
46 }