summaryrefslogblamecommitdiff
path: root/src/network/freeaddrinfo.c
blob: 62241c239e27f8e09a4a437a104f595f69c16255 (plain) (tree)
1
2
3
4
5
6
7
8
                   
                   
                  

                   


                                     






                                                                           
 
#include <stdlib.h>
#include <stddef.h>
#include <netdb.h>
#include "lookup.h"
#include "lock.h"

void freeaddrinfo(struct addrinfo *p)
{
	size_t cnt;
	for (cnt=1; p->ai_next; cnt++, p=p->ai_next);
	struct aibuf *b = (void *)((char *)p - offsetof(struct aibuf, ai));
	b -= b->slot;
	LOCK(b->lock);
	if (!(b->ref -= cnt)) free(b);
	else UNLOCK(b->lock);
}