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


Groups > comp.unix.programmer > #1187

Re: the usage of getaddrinfo()

From John Gordon <gordon@panix.com>
Newsgroups comp.unix.programmer
Subject Re: the usage of getaddrinfo()
Date 2011-08-24 17:29 +0000
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <j33cd5$oip$1@reader1.panix.com> (permalink)
References <3e76da03-f115-45da-a1d3-fb3b4d35de56@glegroupsg2000goo.googlegroups.com>

Show all headers | 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