void FreePunc(FcitxPuncState* puncState) { puncState->curPunc = NULL; FcitxPunc* cur; while (puncState->puncSet) { cur = puncState->puncSet; HASH_DEL(puncState->puncSet, cur); free(cur->langCode); free(cur->curPunc); free(cur); } }
void delete_file_descriptor_table(int pid) { struct file_descriptor_table * table; table = get_file_descriptor_table(pid); if (table) { HASH_DEL(file_descriptor_tables, table); free(table->entries); free(table); } }
bool consolidate_gsub_single(caryll_font *font, table_otl *table, otl_subtable *_subtable, sds lookupName) { subtable_gsub_single *subtable = &(_subtable->gsub_single); consolidate_coverage(font, subtable->from, lookupName); consolidate_coverage(font, subtable->to, lookupName); uint16_t len = (subtable->from->numGlyphs < subtable->to->numGlyphs ? subtable->from->numGlyphs : subtable->from->numGlyphs); gsub_single_map_hash *h = NULL; for (uint16_t k = 0; k < len; k++) { if (subtable->from->glyphs[k].name && subtable->to->glyphs[k].name) { gsub_single_map_hash *s; int fromid = subtable->from->glyphs[k].gid; HASH_FIND_INT(h, &fromid, s); if (s) { fprintf(stderr, "[Consolidate] Double-mapping a glyph in a " "single substitution /%s.\n", subtable->from->glyphs[k].name); } else { NEW(s); s->fromid = subtable->from->glyphs[k].gid; s->toid = subtable->to->glyphs[k].gid; s->fromname = subtable->from->glyphs[k].name; s->toname = subtable->to->glyphs[k].name; HASH_ADD_INT(h, fromid, s); } } } HASH_SORT(h, by_from_id); if (HASH_COUNT(h) != subtable->from->numGlyphs || HASH_COUNT(h) != subtable->to->numGlyphs) { fprintf(stderr, "[Consolidate] In single subsitution lookup %s, some " "mappings are ignored.\n", lookupName); } subtable->from->numGlyphs = HASH_COUNT(h); subtable->to->numGlyphs = HASH_COUNT(h); FREE(subtable->from->glyphs); FREE(subtable->to->glyphs); NEW_N(subtable->from->glyphs, subtable->from->numGlyphs); NEW_N(subtable->to->glyphs, subtable->to->numGlyphs); { gsub_single_map_hash *s, *tmp; uint16_t j = 0; HASH_ITER(hh, h, s, tmp) { subtable->from->glyphs[j].gid = s->fromid; subtable->from->glyphs[j].name = s->fromname; subtable->to->glyphs[j].gid = s->toid; subtable->to->glyphs[j].name = s->toname; j++; HASH_DEL(h, s); free(s); } }
/* when an object is deleted */ void cache_destroy(struct giga_directory *dir) { assert(dir->refcount > 1); /* once to release from the caller */ __sync_fetch_and_sub(&dir->refcount, 1); HASH_DEL(dircache, dir); if (__sync_sub_and_fetch(&dir->refcount, 1) == 0) free(dir); }
void augroup_remove(char *key) { log_msg("HOOK", "GROUP REMOVE"); Augroup *find; HASH_FIND_STR(aug_tbl, key, find); if (!find) return; HASH_DEL(aug_tbl, find); free(find->key); free(find); }
void UnloadSingleImage(FcitxSkin* sc, const char* name) { SkinImage *image; HASH_FIND_STR(sc->imageTable, name, image); if (image != NULL) { SkinImage* curimage = image; HASH_DEL(sc->imageTable, image); free(curimage->name); cairo_surface_destroy(curimage->image); free(curimage); } }
void delete_all () { User *current_user; while (users) { current_user = users; /* grab pointer to first item */ HASH_DEL (users, current_user); /* delete it (users advances to next) */ free (current_user); /* free it */ } }
void rel_delete(rel_hash *r) { printf("\n<-- delete a rel node -->\n"); if(r) { pthread_mutex_lock(&rq->node[r->loc].mutex); rq->node[r->loc].isDelete = 1; pthread_mutex_unlock(&rq->node[r->loc].mutex); HASH_DEL(rhs, r); free(r); } }
void delete_proc_hash(mem_proc_t *mem_proc) { //HASH_CLEAR(hh, mem_proc); mem_proc_t *tmp_mem, *cur_mem; HASH_ITER(hh, mem_proc, cur_mem, tmp_mem) { if(mem_proc != cur_mem) HASH_DEL(mem_proc, cur_mem); if(cur_mem) free(cur_mem); } //if(mem_proc) free(mem_proc); }
/* Delete specify queue by queue name from hash table */ void hash_del_queue(const char* qname) { mq_queue_list_t* tmp_queue = NULL; HASH_FIND_STR(g_mq_qlist, qname, tmp_queue); if (tmp_queue != NULL) { log_debug("Del queue [%s]\n", tmp_queue->qname); HASH_DEL(g_mq_qlist, tmp_queue); /* user: pointer to deletee */ free(tmp_queue); /* optional; it��s up to you! */ } }
void UnloadImage(FcitxSkin* skin) { SkinImage *images = skin->imageTable; while (images) { SkinImage* curimage = images; HASH_DEL(images, curimage); free(curimage->name); cairo_surface_destroy(curimage->image); free(curimage); } skin->imageTable = NULL; }
dessert_per_result_t send_tc(void *data, struct timeval *scheduled, struct timeval *interval) { pthread_rwlock_wrlock(&pp_rwlock); if (HASH_COUNT(dir_neighbors_head) == 0) { return 0; } dessert_msg_t *tc; dessert_msg_new(&tc); tc->ttl = TTL_MAX; tc->u8 = ++tc_seq_nr; // delete old entries from NH list node_neighbors_t *dir_neigh = dir_neighbors_head; while (dir_neigh) { if (dir_neigh->entry_age-- == 0) { node_neighbors_t* el_to_delete = dir_neigh; HASH_DEL(dir_neighbors_head, el_to_delete); free(el_to_delete); } dir_neigh = dir_neigh->hh.next; } // add TC extension dessert_ext_t *ext; uint8_t ext_size = 1 + ((sizeof(node_neighbors_t)- sizeof(dir_neighbors_head->hh)) * HASH_COUNT(dir_neighbors_head)); dessert_msg_addext(tc, &ext, LSR_EXT_TC, ext_size); void* tc_ext = ext->data; memcpy(tc_ext, &(ext_size), 1); tc_ext++; // copy NH list into extension dir_neigh = dir_neighbors_head; while (dir_neigh) { memcpy(tc_ext, dir_neigh->addr, ETH_ALEN); tc_ext += ETH_ALEN; memcpy(tc_ext, &(dir_neigh->entry_age), 1); tc_ext++; memcpy(tc_ext, &(dir_neigh->weight), 1); tc_ext++; dir_neigh = dir_neigh->hh.next; } // add l2.5 header dessert_msg_addext(tc, &ext, DESSERT_EXT_ETH, ETHER_HDR_LEN); struct ether_header* l25h = (struct ether_header*) ext->data; memcpy(l25h->ether_shost, dessert_l25_defsrc, ETH_ALEN); memcpy(l25h->ether_dhost, ether_broadcast, ETH_ALEN); dessert_meshsend_fast(tc, NULL); dessert_msg_destroy(tc); pthread_rwlock_unlock(&pp_rwlock); return 0; }
PRIVATE void __AI_correlation_table_cleanup () { AI_alert_correlation *current; while ( correlation_table ) { current = correlation_table; HASH_DEL ( correlation_table, current ); free ( current ); } } /* ----- end of function __AI_correlation_table_cleanup ----- */
static void springfield_iter_i(springfield_t *r, springfield_iter_cb cb, springfield_readonly_iter_cb rocb, void *passthrough) { /* Copy into temporary buffer */ if (cb) { assert(!rocb); } else { assert(rocb); } int i; for (i = 0; i < r->num_buckets; i++) { uint64_t off = r->offsets[i]; springfield_key_t *key = NULL, *tmp = NULL; springfield_key_t *keys = NULL; pthread_rwlock_rdlock(&r->main_lock); while (off != NO_BACKTRACE) { springfield_header_v1 *h = (springfield_header_v1 *)(r->map + off); int klen = h->klen - 1; char *keyptr = (char *)(r->map + off + HEADER_SIZE); HASH_FIND(hh, keys, keyptr, klen, key); uint64_t last = h->last; if (!key) { /* not found */ key = calloc(1, sizeof(springfield_key_t)); key->key = strdup(keyptr); int do_callback = h->vlen > 0; if (do_callback) { if (cb) { pthread_rwlock_unlock(&r->main_lock); cb(r, key->key, passthrough); pthread_rwlock_rdlock(&r->main_lock); } else { pthread_rwlock_unlock(&r->main_lock); rocb(r, key->key, r->map + off + HEADER_SIZE + h->klen, h->vlen, passthrough); pthread_rwlock_rdlock(&r->main_lock); } } /* set in hash */ HASH_ADD_KEYPTR(hh, keys, key->key, klen, key); } off = last; } pthread_rwlock_unlock(&r->main_lock); /* cleanup keys XXX */ HASH_ITER(hh, keys, key, tmp) { HASH_DEL(keys, key); free(key->key); free(key); } }
/** * Trim a clustering by rejecting small clusters. The provided clustering * structure is updated by assigning reports of rejected clusters to the * cluster label 0. * @param c Clustering structure */ void cluster_trim(cluster_t *c) { assert(c); count_t *counts = NULL, *entry; unsigned int i, j; int rej; config_lookup_int(&cfg, "cluster.reject_num", &rej); for (i = 0; i < c->len; i++) { /* Look for cluster in hash table */ HASH_FIND_INT(counts, &(c->cluster[i]), entry); if (!entry) { entry = malloc(sizeof(count_t)); if (!entry) { error("Could not allocate cluster bin"); return; } /* Create new entry */ entry->label = c->cluster[i]; entry->count = 0; /* Add entry */ HASH_ADD_INT(counts, label, entry); } entry->count++; } /* Update cluster assignments */ for (i = 0; i < c->len; i++) { /* Look for cluster in hash table */ HASH_FIND_INT(counts, &(c->cluster[i]), entry); if (entry->count >= rej) c->cluster[i] = entry->label; else c->cluster[i] = 0; } /* Delete hash table */ for (j = 0; counts;) { /* Count rejected clusters */ entry = counts; if (entry->count < rej) j++; HASH_DEL(counts, entry); free(entry); } /* Correct cluster number */ c->num -= j; }
int matchInodefiles(void) { fileop_t *f; fileop_t *finode; char fpath[PATH_MAX]; struct stat st; int64_t inode; // first try to match inodefiles to files for (f = files; f != NULL; f = (fileop_t*) (f->hh.next)) { // get ino of the file getAbsolutePath(fpath, config.snapshot, f->relpath); if (stat(fpath, &st) != -1) { inode = st.st_ino; } else { // this should not happen: we can't open the file errMsg(LOG_WARNING, "Could not stat file %s ", fpath); } // if this ino is in inodefiles, merge the operations in f and // remove the element from inodefiles // TODO: what about order? HASH_FIND_INT(inodefiles, &inode, finode); if (finode != NULL) { if (mergeOperations(f, finode) != 0) return -1; free(finode->operations); HASH_DEL(inodefiles, finode); free(finode); } // if there are no entries in inodefiles left, we are done if (HASH_COUNT(inodefiles) == 0) // HASH_COUNT is cheap return 0; } // the rest must be matched by file tree walk (nftw) int flags = 0; flags |= FTW_MOUNT; // stay in the file system flags |= FTW_PHYS; // do not dereference symlinks if (nftw(config.snapshot, matchInode, 10, flags) == -1) { errMsg(LOG_WARNING, "Could not stat file %s ", fpath); } // if there are still some entries left in inodefiles, we have a problem if (HASH_COUNT(inodefiles) == 0) return 0; else return -1; }
double __AI_get_alerts_heterogeneity ( int *alert_count ) { double heterogeneity = 0.0; int distinct_count = 0; AI_hyperalert_key key; AI_snort_alert *alert_iterator = NULL; AI_alert_occurrence *table = NULL, *found = NULL; *alert_count = 0; for ( alert_iterator = alert_log; alert_iterator; alert_iterator = alert_iterator->next ) { found = NULL; *alert_count += alert_iterator->grouped_alerts_count; key.gid = alert_iterator->gid; key.sid = alert_iterator->sid; key.rev = alert_iterator->rev; HASH_FIND ( hh, table, &key, sizeof ( AI_hyperalert_key ), found ); if ( !found ) { if ( !( found = (AI_alert_occurrence*) malloc ( sizeof ( AI_alert_occurrence )))) AI_fatal_err ( "Fatal dynamic memory allocation error", __FILE__, __LINE__ ); found->key = key; found->count = 1; HASH_ADD ( hh, table, key, sizeof ( AI_hyperalert_key ), found ); } else { found->count++; } } for ( found = table; found; found = (AI_alert_occurrence*) found->hh.next ) distinct_count++; if ( *alert_count > 0 ) heterogeneity = (double) distinct_count / (double) *alert_count; else heterogeneity = 0.0; while ( table ) { found = table; HASH_DEL ( table, found ); free ( found ); } return heterogeneity; } /* ----- end of function __AI_get_alerts_heterogeneity ----- */
void MAT_PARSER_free(Parser* p) { // Local variables MAT_Parser* parser = (MAT_Parser*)PARSER_get_data(p); // No parser if (!parser) return; // Buses while (parser->bus_hash) HASH_DEL(parser->bus_hash,parser->bus_hash); LIST_map(MAT_Bus,parser->bus_list,bus,next,{free(bus);});
/* Deallocate variable hash. */ static void free_var_hash (struct id_defined *head) { struct id_defined *el, *tmp; HASH_ITER (hh, head, el, tmp) { struct tree_hash_node *hel, *tmp; if (el->phi_node) HASH_FREE (hh, el->phi_node, hel, tmp); HASH_DEL (head, el); free (el); } }
void resetSeqLog() { seqlog_t* current; pthread_rwlock_wrlock(&seqlog_lock); while(seqlog) { current = seqlog; HASH_DEL(seqlog, current); free(current); } pthread_rwlock_unlock(&seqlog_lock); dessert_notice("sequence number log flushed"); }
void destroyStackForExitingThread(JAVA_LONG threadId) { struct hash_struct *s; HASH_FIND_JAVA_LONG((struct hash_struct *)*threadToStackTraceMapPtr, &threadId, s); if (s == NULL) { printf("ERROR: Unable to destroy stack trace for exiting thread!\n"); exit(-1); } else { HASH_DEL((struct hash_struct *)*threadToStackTraceMapPtr, s); free(s->value); free(s); } }
int kmparticle_id(int id) { particle_t* p = particle(id); if(p == NULL) { return -1; } HASH_DEL(particles, p); remove_body(p->body); free(p); return 0; }
void resetPacketTrap() { trappedpacket_t* current; pthread_rwlock_wrlock(&packettrap_lock); while(trappedpackets) { current = trappedpackets; HASH_DEL(trappedpackets, current); destroyTrappedPacket(current); } pthread_rwlock_unlock(&packettrap_lock); dessert_notice("packet trap flushed"); }
int del_cb(char *mod, char *cb) { Module modu = NULL; ModFunc modf = NULL; HASH_FIND_STR(mods, mod, modu); if (modu != NULL) { HASH_FIND_STR(modu->funcs, cb, modf); if (modf != NULL) { HASH_DEL(modu->funcs, modf); free(modf); } } return 0; };
void delete_unit_hash(link_unit_t *hash_unit, mem_unit_t *hash_mem) { // HASH_CLEAR(hh, hash_unit); // HASH_CLEAR(hh, hash_mem); link_unit_t *tmp_unit, *cur_unit; mem_unit_t *tmp_mem, *cur_mem; HASH_ITER(hh, hash_unit, cur_unit, tmp_unit) { if(hash_unit != cur_unit) HASH_DEL(hash_unit, cur_unit); if(cur_unit) free(cur_unit); } //if(hash_unit) free(hash_unit); HASH_ITER(hh, hash_mem, cur_mem, tmp_mem) { if(hash_mem != cur_mem) HASH_DEL(hash_mem, cur_mem); if(cur_mem) free(cur_mem); } //if(hash_mem) free(hash_mem); }
void SoundDataManager::unloadEffect(int nSoundID) { do { tEffectElement* pElement = NULL; HASH_FIND_INT(m_pEffects, &nSoundID, pElement); BREAK_IF(!pElement); delete [] (pElement->pDataBuffer); HASH_DEL(m_pEffects, pElement); free(pElement); } while (0); }
static int efa_av_remove(struct fid_av *av_fid, fi_addr_t *fi_addr, size_t count, uint64_t flags) { struct efa_av *av = container_of(av_fid, struct efa_av, av_fid); struct efa_conn *conn = NULL; char str[INET6_ADDRSTRLEN]; int ret = 0; int i; if (!fi_addr || (av->type != FI_AV_MAP && av->type != FI_AV_TABLE)) return -FI_EINVAL; for (i = 0; i < count; i++) { struct efa_reverse_av *reverse_av; struct efa_ah_qpn key; if (fi_addr[i] == FI_ADDR_NOTAVAIL) continue; if (av->type == FI_AV_MAP) { conn = (struct efa_conn *)fi_addr[i]; } else { /* (av->type == FI_AV_TABLE) */ conn = av->conn_table[fi_addr[i]]; av->conn_table[fi_addr[i]] = NULL; av->next = MIN(av->next, fi_addr[i]); } if (!conn) continue; key.efa_ah = conn->ah->efa_address_handle; key.qpn = conn->ep_addr.qpn; HASH_FIND(hh, av->reverse_av, &key, sizeof(key), reverse_av); if (OFI_LIKELY(!!reverse_av)) { HASH_DEL(av->reverse_av, reverse_av); free(reverse_av); } ret = efa_cmd_destroy_ah(conn->ah); if (ret) return ret; memset(str, 0, sizeof(str)); inet_ntop(AF_INET6, conn->ep_addr.raw, str, INET6_ADDRSTRLEN); EFA_INFO(FI_LOG_AV, "av_remove conn[%p] with GID[%s] QP[%u]\n", conn, str, conn->ep_addr.qpn); free(conn); av->used--; } return ret; }
UnicodeSet* UnicodeSetIntersect(UnicodeSet* left, UnicodeSet* right) { do { if (!left) break; if (!right) break; UnicodeSet* p = left; while (p) { UnicodeSet* find = NULL; HASH_FIND_UNICODE(right, &p->unicode, find); UnicodeSet* next = p->hh.next; if (!find) { HASH_DEL(left, p); free(p); } else { HASH_DEL(right, find); free(find); } p = next; } UnicodeSetFree(right); return left; } while(0); if (left) UnicodeSetFree(left); if (right) UnicodeSetFree(right); return NULL; }
void clear_ipports() { struct ipport_items *s, *tmp; if (pthread_rwlock_wrlock(&ipport_lock) != 0) { LERR("can't acquire write lock"); exit(-1); } /* free the hash table contents */ HASH_ITER(hh, ipports, s, tmp) { HASH_DEL(ipports, s); free(s); }
static int free_hint_handles(void *ignore) { int mpi_errno = MPI_SUCCESS; struct MPIR_Comm_hint_fn_elt *curr_hint = NULL, *tmp = NULL; MPID_MPI_STATE_DECL(MPID_STATE_MPIR_COMM_FREE_HINT_HANDLES); MPID_MPI_FUNC_ENTER(MPID_STATE_MPIR_COMM_FREE_HINT_HANDLES); if (MPID_hint_fns) { HASH_ITER(hh, MPID_hint_fns, curr_hint, tmp) { HASH_DEL(MPID_hint_fns, curr_hint); MPIU_Free(curr_hint); } }