• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <stdlib.h>
2 #include <stddef.h>
3 #include <netdb.h>
4 #include "lookup.h"
5 #include "lock.h"
6 
freeaddrinfo(struct addrinfo * p)7 void freeaddrinfo(struct addrinfo *p)
8 {
9 	if (!p) {
10 		return;
11 	}
12 	size_t cnt;
13 	struct aibuf *b = (void *)((char *)p - offsetof(struct aibuf, ai));
14 	for (cnt=1; p->ai_next; cnt++, p=p->ai_next);
15 	LOCK(b->lock);
16 	if (!(b->ref -= cnt)) free(b);
17 	else UNLOCK(b->lock);
18 }
19