freeaddrinfo.c revision 256281
1193323Sed/*
2193323Sed * Copyright (c) 1999 - 2001 Kungliga Tekniska H��gskolan
3193323Sed * (Royal Institute of Technology, Stockholm, Sweden).
4193323Sed * All rights reserved.
5193323Sed *
6193323Sed * Redistribution and use in source and binary forms, with or without
7193323Sed * modification, are permitted provided that the following conditions
8193323Sed * are met:
9193323Sed *
10193323Sed * 1. Redistributions of source code must retain the above copyright
11193323Sed *    notice, this list of conditions and the following disclaimer.
12193323Sed *
13193323Sed * 2. Redistributions in binary form must reproduce the above copyright
14193323Sed *    notice, this list of conditions and the following disclaimer in the
15193323Sed *    documentation and/or other materials provided with the distribution.
16239462Sdim *
17239462Sdim * 3. Neither the name of the Institute nor the names of its contributors
18193323Sed *    may be used to endorse or promote products derived from this software
19218893Sdim *    without specific prior written permission.
20249423Sdim *
21249423Sdim * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
22249423Sdim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23249423Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24249423Sdim * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
25249423Sdim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26249423Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27249423Sdim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28249423Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29249423Sdim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30239462Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31218893Sdim * SUCH DAMAGE.
32193323Sed */
33193323Sed
34234353Sdim#include <config.h>
35234353Sdim
36234353Sdim#include "roken.h"
37193323Sed
38234353Sdim/*
39234353Sdim * free the list of `struct addrinfo' starting at `ai'
40234353Sdim */
41193323Sed
42193323SedROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
43223017Sdimfreeaddrinfo(struct addrinfo *ai)
44223017Sdim{
45223017Sdim    struct addrinfo *tofree;
46239462Sdim
47239462Sdim    while(ai != NULL) {
48239462Sdim	free (ai->ai_canonname);
49239462Sdim	free (ai->ai_addr);
50234353Sdim	tofree = ai;
51226633Sdim	ai = ai->ai_next;
52223017Sdim	free (tofree);
53226633Sdim    }
54234353Sdim}
55226633Sdim