strncpy(ghbn_cache[lowi].name,name,128); memcpy((char *)&(ghbn_cache[lowi].ent),ret,sizeof(struct hostent)); ghbn_cache[lowi].order=ghbn_miss+ghbn_hits;
if(strlen(name) < sizeof ghbn_cache[0].name) { strcpy(ghbn_cache[lowi].name,name); memcpy((char *)&(ghbn_cache[lowi].ent),ret,sizeof(struct hostent)); ghbn_cache[lowi].order=ghbn_miss+ghbn_hits; }
static struct hostent *GetHostByName(char *name)	{	struct hostent *ret;	int i,lowi=0;	unsigned long low= (unsigned long)-1;	for (i=0; i<GHBN_NUM; i++)		{		if (low > ghbn_cache[i].order)			{			low=ghbn_cache[i].order;			lowi=i;			}		if (ghbn_cache[i].order > 0)			{			if (strncmp(name,ghbn_cache[i].name,128) == 0)				break;			}		}	if (i == GHBN_NUM) /* no hit*/		{		ghbn_miss++;		ret=gethostbyname(name);		if (ret == NULL) return(NULL);		/* else add to cache */		strncpy(ghbn_cache[lowi].name,name,128);		memcpy((char *)&(ghbn_cache[lowi].ent),ret,sizeof(struct hostent));		ghbn_cache[lowi].order=ghbn_miss+ghbn_hits;		return(ret);		}	else		{		ghbn_hits++;		ret= &(ghbn_cache[i].ent);		ghbn_cache[i].order=ghbn_miss+ghbn_hits;		return(ret);		}	}