};
struct SockAddr_tag {
+ int refcount;
const char *error;
enum { UNRESOLVED, UNIX, IP } superfamily;
#ifndef NO_IPV6
ret->superfamily = UNRESOLVED;
*realhost = '\0';
ret->error = NULL;
+ ret->refcount = 1;
#ifndef NO_IPV6
hints.ai_flags = AI_CANONNAME;
#else
ret->addresses = NULL;
#endif
+ ret->refcount = 1;
return ret;
}
void sk_addr_free(SockAddr addr)
{
-
+ if (--addr->refcount > 0)
+ return;
#ifndef NO_IPV6
if (addr->ais != NULL)
freeaddrinfo(addr->ais);
sfree(addr);
}
+SockAddr sk_addr_dup(SockAddr addr)
+{
+ addr->refcount++;
+ return addr;
+}
+
static Plug sk_tcp_plug(Socket sock, Plug p)
{
Actual_Socket s = (Actual_Socket) sock;
ret->addresses = NULL;
ret->naddresses = 0;
#endif
+ ret->refcount = 1;
return ret;
}