STATUS virtualStackDelete ( VSID vsid /* VID returned by virtualStackCreate */ ) { int vsIndex; semTake (vsTblLock, WAIT_FOREVER); for (vsIndex = 0; vsIndex < VSID_MAX; vsIndex++) if (vsTbl[vsIndex] == vsid) break; /* Hey, we found it! */ /* Check that we did find it. */ if (vsIndex == VSID_MAX) { semGive (vsTblLock); return (ERROR); } /* Free the structure. */ KHEAP_FREE (vsTbl[vsIndex]); /* Let's be extra paranoid. */ vsTbl[vsIndex] = NULL; semGive (vsTblLock); return (OK); }
int etherMultiDel ( LIST *pList, /* pointer to list of multicast addresses */ char* pAddress /* address you want to add to list */ ) { ETHER_MULTI* pCurr; /* * Look up the address in our list. */ for (pCurr = (ETHER_MULTI *)lstFirst(pList); pCurr != NULL && (bcmp(pCurr->addr, pAddress, 6) != 0); pCurr = (ETHER_MULTI *)lstNext(&pCurr->node)); if (pCurr == NULL) { return (ENXIO); } if (--pCurr->refcount != 0) { /* * Still some claims to this record. */ return (0); } /* * No remaining claims to this record; unlink and free it. */ lstDelete(pList, &pCurr->node); KHEAP_FREE((char *)pCurr); /* * Return ENETRESET to inform the driver that the list has changed * and its reception filter should be adjusted accordingly. */ return (ENETRESET); }
void * _mbufLibInit (void) { int ix; /* counter for list init */ if (mbufInit == TRUE) /* already initialized ? */ return ((void *) &mbufFunc); if ((_mbufIdHead = (MBUF_ID) KHEAP_ALLOC((sizeof (struct mbufId) * MBUF_ID_INC))) == NULL) /* alloc space for ID list */ return (NULL); if ((mbufDescHead = (MBUF_DESC) KHEAP_ALLOC((sizeof (struct mbufDesc) * MBUF_DESC_INC))) == NULL) /* alloc space for desc list */ { KHEAP_FREE((char *)_mbufIdHead); return (NULL); } /* divide up into an sll of free mbuf ID's, _mbufIdHead as the head */ for (ix = 0; ix < (MBUF_ID_INC - 1); ix++) _mbufIdHead[ix].mbufIdNext = &_mbufIdHead[ix + 1]; _mbufIdHead[ix].mbufIdNext = NULL; /* divide up into an sll of free buf desc, mbufDescHead as the head */ for (ix = 0; ix < (MBUF_DESC_INC - 1); ix++) mbufDescHead[ix].mbufDescNext = &mbufDescHead[ix + 1]; mbufDescHead[ix].mbufDescNext = NULL; mbufInit = TRUE; /* init successful */ return ((void *) &mbufFunc); /* return mbuf func table */ }
void routeEntryFree ( ROUTE_ENTRY * pRouteEntry, /* existing duplicate route entry */ BOOL countFlag /* decrement interface reference count? */ ) { if (countFlag && pRouteEntry->rtEntry.rt_ifa) pRouteEntry->rtEntry.rt_ifa->ifa_refcnt--; if(pRouteEntry->rtEntry.rt_genmask) KHEAP_FREE( (char *)pRouteEntry->rtEntry.rt_genmask); if(pRouteEntry->rtEntry.rt_nodes[0].rn_u.rn_leaf.rn_Mask) KHEAP_FREE(pRouteEntry->rtEntry.rt_nodes[0].rn_u.rn_leaf.rn_Mask); KHEAP_FREE( (char *)pRouteEntry); }
void endObjectUnload ( END_OBJ* pEnd ) { if (pEnd->txSem != NULL) semDelete (pEnd->txSem); lstFree (&pEnd->multiList); if (pEnd->pSnarf != NULL) { KHEAP_FREE (pEnd->pSnarf); } pEnd->dummyBinding = NULL; pEnd->pSnarf = NULL; pEnd->pTyped = NULL; pEnd->pPromisc = NULL; pEnd->pStop = NULL; pEnd->nProtoSlots = 0; }
STATUS hostDelete ( char *name, /* host name or alias */ char *addr /* host addr in standard Internet format */ ) { HOSTNAME *pHostNamePrev; /* pointer to previous host name entry */ HOSTNAME *pHostNameNext; /* pointer to next host name entry */ FAST HOSTNAME *pHostName; FAST HOSTENTRY *pHostEntry; struct in_addr netAddr; if (name == NULL || addr == NULL) { errnoSet (S_hostLib_INVALID_PARAMETER); return (ERROR); } /* convert from string to int format */ if ((netAddr.s_addr = inet_addr (addr)) == ERROR) return ERROR; semTake (hostListSem, WAIT_FOREVER); /* search inet address */ for (pHostEntry = (HOSTENTRY *)lstFirst (&hostList); pHostEntry != NULL; pHostEntry = (HOSTENTRY *)lstNext (&pHostEntry->node)) { if (pHostEntry->netAddr.s_addr != netAddr.s_addr) continue; if (strcmp (pHostEntry->hostName.name, name) == 0) /* given name is exact match */ { FAST HOSTNAME * pAlias = pHostEntry->hostName.link; FAST HOSTNAME * pNext = NULL; /* free all associated alias(es) 1st if any, then free itself */ for ( ; pAlias != NULL; pAlias = pNext) { pNext = pAlias->link; KHEAP_FREE(pAlias->name); KHEAP_FREE((char *) pAlias); } lstDelete (&hostList, &pHostEntry->node); semGive (hostListSem); KHEAP_FREE(pHostEntry->hostName.name); KHEAP_FREE((char *) pHostEntry); return (OK); } else /* given name is an alias */ { for (pHostNamePrev = pHostName = &pHostEntry->hostName; pHostName != NULL; pHostNamePrev = pHostName, pHostName = pHostName->link) { pHostNameNext = pHostName->link; if (strcmp (pHostName->name, name) == 0) /* found alias */ { pHostNamePrev->link = pHostNameNext; semGive (hostListSem); KHEAP_FREE(pHostName->name); KHEAP_FREE((char *) pHostName); return (OK); } } } } errnoSet (S_hostLib_UNKNOWN_HOST); semGive (hostListSem); return (ERROR); }