Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.unix.programmer > #1187

Re: the usage of getaddrinfo()

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nx02.iad01.newshosting.com!newshosting.com!news-out.readnews.com!transit3.readnews.com!panix!gordon
From John Gordon <gordon@panix.com>
Newsgroups comp.unix.programmer
Subject Re: the usage of getaddrinfo()
Date Wed, 24 Aug 2011 17:29:10 +0000 (UTC)
Organization PANIX Public Access Internet and UNIX, NYC
Lines 26
Message-ID <j33cd5$oip$1@reader1.panix.com> (permalink)
References <3e76da03-f115-45da-a1d3-fb3b4d35de56@glegroupsg2000goo.googlegroups.com>
NNTP-Posting-Host panix1.panix.com
X-Trace reader1.panix.com 1314206950 25177 166.84.1.1 (24 Aug 2011 17:29:10 GMT)
X-Complaints-To abuse@panix.com
NNTP-Posting-Date Wed, 24 Aug 2011 17:29:10 +0000 (UTC)
User-Agent nn/6.7.3
Xref x330-a1.tempe.blueboxinc.net comp.unix.programmer:1187

Show key headers only | View raw


In <3e76da03-f115-45da-a1d3-fb3b4d35de56@glegroupsg2000goo.googlegroups.com> wy <warmyouth@gmail.com> writes:

> Now there is a question:
> In the example, it declares struct addrinfo *ailist, *aip;
> And ailist is used in a for loop:
> 	for (aip = ailist; aip != NULL; aip = aip->ai_next) {
>                 ...
> 		printf("\n host:  \t%s", aip->ai_canonname?aip->ai_canonname:"-");
>                 ...
> 	}
> But where is the memory aip pointer to, in the for loop?

aip points to the ailist pointer, for which memory was allocated in
the call to getaddrinfo().

> in the example, it doesn't call freeaddrinfo() to free the allocated
> memory, and so does in the later examples, which is thought to cause
> memory leakage.

All memory is freed when the program exits.

-- 
John Gordon                   A is for Amy, who fell down the stairs
gordon@panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"

Back to comp.unix.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

the usage of getaddrinfo() wy <warmyouth@gmail.com> - 2011-08-24 00:43 -0700
  Re: the usage of getaddrinfo() Rainer Weikusat <rweikusat@mssgmbh.com> - 2011-08-24 13:09 +0100
    Re: the usage of getaddrinfo() wy <warmyouth@gmail.com> - 2011-08-26 01:25 -0700
      Re: the usage of getaddrinfo() David Schwartz <davids@webmaster.com> - 2011-08-26 02:54 -0700
      Re: the usage of getaddrinfo() John Gordon <gordon@panix.com> - 2011-08-26 13:44 +0000
        Re: the usage of getaddrinfo() Rick Jones <rick.jones2@hp.com> - 2011-08-26 21:41 +0000
          Re: the usage of getaddrinfo() Rainer Weikusat <rweikusat@mssgmbh.com> - 2011-08-28 17:18 +0100
  Re: the usage of getaddrinfo() John Gordon <gordon@panix.com> - 2011-08-24 17:29 +0000

csiph-web