On Fri, Feb 08, 2008, Amos Jeffries wrote:

> Try it. You will be horrified.

Why? Whats being trashed, AI, or AI->somemember?

If AI is being trashed, then just create a temporary pointer copy
of AI, use that in the socket call, and then throw it away.
if its trashing the memory -at- the AI rather than the AI pointer
itself then you should probably spend some time with valgrind.

> The pointer-tree needs by the OS to work with screws that up. We would
> need to allocate a new addrinfo for each master node and set its pointers
> to new memory, copy the original data into it ... and hey! thats what
> IPAddress::GetAddrInfo() does!

It doesn't do that in C! I don't get it.

> Do not confuse IPAddress::GetAddrInfo() which allocates an initializes a
> 'full' one-IP addrinfo* tree quickly which is about to be used in place of
> a blocking getaddrinfo() system call.
> 
> The second-best alternative in many of these places is hard-coding
> sockaddr_in* types and using #if USE_IPV6 to alternate the calls.

> With IPAddress::InitAddrInfo() which allocates a single empty addrinfo*
> ready for new data to be inserted and only sets the flags up.

Are there any situations where you iterate over a list of AddrInfo's ?

You're not passing in a struct addr_info which you've allocated yourself into
a glibc call which then frobs it and possibly allocates another?




Adrian

Reply via email to