[Raw Msg Headers][Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

BSD freeadrinfo() implementation Was: smtp TA's SIGSEGV in getmxrr()

On Thu, Nov 16, 2000 at 07:06:51PM +0200, Matti Aarnio wrote:
>    Could you check what BSD libc does in  freeaddrinfo()  ?
>    Is the  struct addrinfo  block really single one, or is it
>    made of multiple segments, which need separate  free() calls ?
>    (glibc's  'struct addrinfo' is single block where its head has
>     the common structure, then it has address(es), and finally
>     the ai_canonname buffer -- all of it will be freed when
>     that leading structure is freed.)

That one is from FreeBSD 4.2-BETA. Probably standard KAME code.
You see, canonname is in separate chunk.

        struct addrinfo *ai;
        struct addrinfo *next;

        do {
                next = ai->ai_next;
                if (ai->ai_canonname)
                /* no need to free(ai->ai_addr) */
                ai = next;
        } while (ai);

OpenBSD has almost exactly the same code but 'next' structure is called 'p'.