int mib_fetch_route(void) { u_char *rtab, *next; size_t len; struct sroute *r, *r1; struct rt_msghdr *rtm; struct sockaddr *addrs[RTAX_MAX]; if (route_tick != 0 && route_tick + ROUTE_UPDATE_INTERVAL > this_tick) return (0); /* * Remove all routes */ r = RB_MIN(sroutes, &sroutes); while (r != NULL) { r1 = RB_NEXT(sroutes, &sroutes, r); RB_REMOVE(sroutes, &sroutes, r); free(r); r = r1; } route_total = 0; if ((rtab = mib_fetch_rtab(AF_INET, NET_RT_DUMP, 0, &len)) == NULL) return (-1); next = rtab; for (next = rtab; next < rtab + len; next += rtm->rtm_msglen) { rtm = (struct rt_msghdr *)(void *)next; if (rtm->rtm_type != RTM_GET || !(rtm->rtm_flags & RTF_UP)) continue; mib_extract_addrs(rtm->rtm_addrs, (u_char *)(rtm + 1), addrs); mib_sroute_process(rtm, addrs[RTAX_GATEWAY], addrs[RTAX_DST], addrs[RTAX_NETMASK]); } #if 0 u_int n = 0; r = RB_MIN(sroutes, &sroutes); while (r != NULL) { printf("%u: ", n++); sroute_print(r); printf("\n"); r = RB_NEXT(sroutes, &sroutes, r); } #endif free(rtab); route_tick = get_ticks(); return (0); }
/* Free an environment. */ void environ_free(struct environ *env) { struct environ_entry *envent, *envent1; RB_FOREACH_SAFE(envent, environ, env, envent1) { RB_REMOVE(environ, env, envent); free(envent->name); free(envent->value); free(envent); }
static void lang_code_free( lang_code_lookup_t *l ) { lang_code_lookup_element_t *element; if (l == NULL) return; while ((element = RB_FIRST(l)) != NULL) { RB_REMOVE(l, element, link); free(element); } free(l); }
void vm_map_store_entry_unlink_rb( struct vm_map_header *mapHdr, vm_map_entry_t entry) { struct rb_head *rbh = &(mapHdr->rb_head_store); struct vm_map_store *rb_entry; struct vm_map_store *store = &(entry->store); rb_entry = RB_FIND( rb_head, rbh, store); if(rb_entry == NULL) panic("NO ENTRY TO DELETE"); RB_REMOVE( rb_head, rbh, store ); }
void ct_rb_unwind(struct ct_match_tree *head) { struct ct_match_node *n; while ((n = RB_ROOT(head)) != NULL) { RB_REMOVE(ct_match_tree, head, n); e_free(&n->cmn_string); e_free(&n); } }
/* Destroy a job tree. */ void job_tree_free(struct jobs *jobs) { struct job *job; while (!RB_EMPTY(jobs)) { job = RB_ROOT(jobs); RB_REMOVE(jobs, jobs, job); job_free(job); } }
/* Destroy (free memory) */ void lang_str_destroy ( lang_str_t *ls ) { lang_str_ele_t *e; if (ls == NULL) return; while ((e = RB_FIRST(ls))) { if (e->str) free(e->str); RB_REMOVE(ls, e, link); free(e); } free(ls); }
void idnode_done(void) { idclass_link_t *il; pthread_cond_signal(&idnode_cond); pthread_join(idnode_tid, NULL); pthread_mutex_lock(&idnode_mutex); htsmsg_destroy(idnode_queue); idnode_queue = NULL; pthread_mutex_unlock(&idnode_mutex); while ((il = RB_FIRST(&idclasses)) != NULL) { RB_REMOVE(&idclasses, il, link); free(il); } while ((il = RB_FIRST(&idrootclasses)) != NULL) { RB_REMOVE(&idrootclasses, il, link); free(il); } SKEL_FREE(idclasses_skel); }
/* Unset an environment variable. */ void environ_unset(struct environ *env, const char *name) { struct environ_entry *envent; if ((envent = environ_find(env, name)) == NULL) return; RB_REMOVE(environ, env, envent); free(envent->name); free(envent->value); free(envent); }
/* Free an environment. */ void environ_free(struct environ *env) { struct environ_entry *envent; while (!RB_EMPTY(env)) { envent = RB_ROOT(env); RB_REMOVE(environ, env, envent); free(envent->name); free(envent->value); free(envent); } }
void *tato_tree_int_remove(TatoTreeInt *thiss, unsigned int key) { TatoTreeIntNode node_scanned; node_scanned.key = key; TatoTreeIntNode *node = RB_FIND(TatoTreeInt_, thiss, &node_scanned); if (!node) return NULL; RB_REMOVE(TatoTreeInt_, thiss, node); void *result = node->value; free(node); return result; }
mpls_return_enum mpls_tree_remove(mpls_tree_handle tree, uint32_t key, int length, void **info) { struct mpls_tree_node *node; node = mpls_tree_find(tree, key, length); if(!node) return MPLS_FAILURE; *info = node->info; RB_REMOVE(mpls_tree, tree, node); mpls_free(node); return MPLS_SUCCESS; }
void intlconv_done( void ) { intlconv_cache_t *ic; pthread_mutex_lock(&intlconv_lock); intlconv_last_ic = NULL; while ((ic = RB_FIRST(&intlconv_all)) != NULL) { iconv_close(ic->ic_handle); free(ic->ic_charset_id); RB_REMOVE(&intlconv_all, ic, ic_link); free(ic); } intlconv_last_src_ic = NULL; while ((ic = RB_FIRST(&intlconv_src_all)) != NULL) { iconv_close(ic->ic_handle); free(ic->ic_charset_id); RB_REMOVE(&intlconv_src_all, ic, ic_link); free(ic); } pthread_mutex_unlock(&intlconv_lock); }
/* * Free tags tree. */ void unloadtags(void) { struct ctag *var, *nxt; for (var = RB_MIN(tagtree, &tags); var != NULL; var = nxt) { nxt = RB_NEXT(tagtree, &tags, var); RB_REMOVE(tagtree, &tags, var); /* line parsed with fparseln needs to be freed */ free(var->tag); free(var); } }
/* Free 32-bit file number generation structures. */ void msdosfs_fileno_free(struct mount *mp) { struct msdosfsmount *pmp = VFSTOMSDOSFS(mp); struct msdosfs_fileno *mf, *next; for (mf = RB_MIN(msdosfs_filenotree, &pmp->pm_filenos); mf != NULL; mf = next) { next = RB_NEXT(msdosfs_filenotree, &pmp->pm_filenos, mf); RB_REMOVE(msdosfs_filenotree, &pmp->pm_filenos, mf); free(mf, M_MSDOSFSFILENO); } }
void ct_extract_free_entry(struct ct_pending_files *head, struct ct_pending_file *file) { struct fnode *fnode; RB_REMOVE(ct_pending_files, head, file); while ((fnode = TAILQ_FIRST(&file->cpf_links)) != NULL) { TAILQ_REMOVE(&file->cpf_links, fnode, fn_list); ct_free_fnode(fnode); } e_free(&file->cpf_name); e_free(&file); }
void Remove_Node(struct FlowNode *node) { #ifdef DEVEL if ( NumFlows == 0 ) { LogError("Remove_Node() Fatal Tried to remove a Node from empty tree"); return; } #endif RB_REMOVE(FlowTree, FlowTree, node); Free_Node(node); NumFlows--; } // End of Lookup_FlowTree
/* Must hold the kqtree_mtx when calling this */ static void kqueue_free(struct kqueue *kq) { RB_REMOVE(kqt, &kqtree, kq); filter_unregister_all(kq); #if defined(__sun__) port_event_t *pe = (port_event_t *) pthread_getspecific(kq->kq_port_event); if (kq->kq_port > 0) close(kq->kq_port); free(pe); #endif free(kq); }
void options_remove(struct options *oo, const char *name) { struct options_entry *o; if ((o = options_find1(oo, name)) == NULL) return; RB_REMOVE(options_tree, &oo->tree, o); free(o->name); if (o->type == OPTIONS_STRING) free(o->str); free(o); }
void expand_free(struct expand *expand) { struct expandnode *xn; if (expand->queue) while ((xn = TAILQ_FIRST(expand->queue))) TAILQ_REMOVE(expand->queue, xn, tq_entry); while ((xn = RB_ROOT(&expand->tree)) != NULL) { RB_REMOVE(expandtree, &expand->tree, xn); free(xn); } }
void Voodoo80211Device:: ieee80211_free_node(struct ieee80211com *ic, struct ieee80211_node *ni) { if (ni == ic->ic_bss) panic("freeing bss node"); DPRINTF(("%s\n", ether_sprintf(ni->ni_macaddr))); RB_REMOVE(ieee80211_tree, &ic->ic_tree, ni); ic->ic_nnodes--; if (RB_EMPTY(&ic->ic_tree)) ic->ic_inact_timer = 0; ieee80211_node_free(ic, ni); /* TBD indicate to drivers that a new node can be allocated */ }
void options_free(struct options *oo) { struct options_entry *o; while (!RB_EMPTY(&oo->tree)) { o = RB_ROOT(&oo->tree); RB_REMOVE(options_tree, &oo->tree, o); free(o->name); if (o->type == OPTIONS_STRING) free(o->str); free(o); } }
void ct_cleanup_login_cache(void) { struct ct_login_cache *tmp; while ((tmp = RB_ROOT(&ct_login_cache)) != NULL) { RB_REMOVE(ct_login_cache_tree, &ct_login_cache, tmp); /* may cache negative entries, uid not found, avoid NULL free */ if (tmp->lc_name != NULL) { e_free(&tmp->lc_name); } e_free(&tmp); } ct_login_cache_size = 0; }
int group_free(struct group *g) { REFCOUNT_DEBUG(g, g->name, g->refcnt); if (--g->refcnt == 0) { RB_REMOVE(group_tree, &groups, g); group_free(g->next); free(g->filename); free(g->sname); free(g); return (0); } return (g->refcnt); }
void Dispose_FlowTree(void) { struct FlowNode *node, *nxt; // Dump all incomplete flows to the file for (node = RB_MIN(FlowTree, FlowTree); node != NULL; node = nxt) { nxt = RB_NEXT(FlowTree, FlowTree, node); RB_REMOVE(FlowTree, FlowTree, node); if ( node->data ) free(node->data); } free(FlowElementCache); FlowElementCache = NULL; FlowNode_FreeList = NULL; CacheOverflow = 0; } // End of Dispose_FlowTree
void vm_map_store_copy_reset_rb( vm_map_copy_t copy, vm_map_entry_t entry, int nentries ) { struct vm_map_header *mapHdr = &(copy->cpy_hdr); struct rb_head *rbh = &(mapHdr->rb_head_store); struct vm_map_store *store; int deleted=0; while (entry != vm_map_copy_to_entry(copy) && nentries > 0) { store = &(entry->store); RB_REMOVE( rb_head, rbh, store ); entry = entry->vme_next; deleted++; nentries--; } }
void peak_track_exit(struct peak_tracks *self) { struct peak_track *flow; if (!self) { return; } while ((flow = RB_ROOT(&self->flows))) { RB_REMOVE(peak_track_tree, &self->flows, flow); prealloc_put(&self->mem, flow); } prealloc_exit(&self->mem); free(self); }
/* Free a tree. */ void format_free(struct format_tree *ft) { struct format_entry *fe, *fe_next; fe_next = RB_MIN(format_tree, ft); while (fe_next != NULL) { fe = fe_next; fe_next = RB_NEXT(format_tree, ft, fe); RB_REMOVE(format_tree, ft, fe); free(fe->value); free(fe->key); free(fe); } free(ft); }
static void bouquet_destroy(bouquet_t *bq) { if (!bq) return; RB_REMOVE(&bouquets, bq, bq_link); idnode_unlink(&bq->bq_id); idnode_set_free(bq->bq_active_services); idnode_set_free(bq->bq_services); assert(bq->bq_services_waiting == NULL); free((char *)bq->bq_chtag_waiting); free(bq->bq_name); free(bq->bq_src); free(bq->bq_comment); free(bq); }
void drm_drawable_free_all(struct drm_device *dev) { struct bsd_drm_drawable_info *info, *next; DRM_SPINLOCK(&dev->drw_lock); for (info = RB_MIN(drawable_tree, &dev->drw_head); info != NULL ; info = next) { next = RB_NEXT(drawable_tree, &dev->drw_head, info); RB_REMOVE(drawable_tree, &dev->drw_head, (struct bsd_drm_drawable_info *)info); DRM_SPINUNLOCK(&dev->drw_lock); free_unr(dev->drw_unrhdr, info->handle); free(info->info.rects, DRM_MEM_DRAWABLE); free(info, DRM_MEM_DRAWABLE); DRM_SPINLOCK(&dev->drw_lock); } DRM_SPINUNLOCK(&dev->drw_lock); }