__res_iclose(res_state statp)
{
	struct __res_state * rp = statp;
	__UCLIBC_MUTEX_LOCK(__resolv_lock);
	if (rp == NULL)
		rp = __res_state();
	__close_nameservers();
	__res_sync = NULL;
#ifdef __UCLIBC_HAS_IPV6__
	{
		char *p1 = (char*) &(rp->nsaddr_list[0]);
		unsigned int m = 0;
		/* free nsaddrs[m] if they do not point to nsaddr_list[x] */
		while (m < ARRAY_SIZE(rp->_u._ext.nsaddrs)) {
			char *p2 = (char*)(rp->_u._ext.nsaddrs[m++]);
			if (p2 < p1 || (p2 - p1) > (signed)sizeof(rp->nsaddr_list))
				free(p2);
		}
	}
#endif
	memset(rp, 0, sizeof(struct __res_state));
	__UCLIBC_MUTEX_UNLOCK(__resolv_lock);
}
__res_iclose(res_state statp)
{
	struct __res_state * rp = statp;
	__UCLIBC_MUTEX_LOCK(__resolv_lock);
	if (rp == NULL)
		rp = __res_state();
	__close_nameservers();
	__res_sync = NULL;
#ifdef __UCLIBC_HAS_IPV6__
	{
		char *p1 = (char*) &(rp->nsaddr_list[0]);
		unsigned int m = 0;
		 
		while (m < ARRAY_SIZE(rp->_u._ext.nsaddrs)) {
			char *p2 = (char*)(rp->_u._ext.nsaddrs[m++]);
			if (p2 < p1 || (p2 - p1) > (signed)sizeof(rp->nsaddr_list))
				free(p2);
		}
	}
#endif
	memset(rp, 0, sizeof(struct __res_state));
	__UCLIBC_MUTEX_UNLOCK(__resolv_lock);
}