void gui_color_palette_free_structs () { if (gui_color_hash_palette_color) hashtable_free (gui_color_hash_palette_color); if (gui_color_hash_palette_alias) hashtable_free (gui_color_hash_palette_alias); if (gui_color_list_with_alias) weelist_free (gui_color_list_with_alias); }
void piggy_close() { if (BitmapBits) free(BitmapBits); if ( SoundBits ) free( SoundBits ); hashtable_free( &AllBitmapsNames ); hashtable_free( &AllDigiSndNames ); }
int main () { hashtable_t* hashtablePtr; long data[] = {3, 1, 4, 1, 5, 9, 2, 6, 8, 7, -1}; long i; puts("Starting..."); hashtablePtr = hashtable_alloc(1, &hash, &comparePairs, -1, -1); for (i = 0; data[i] >= 0; i++) { insertInt(hashtablePtr, &data[i]); assert(*(long*)hashtable_find(hashtablePtr, &data[i]) == data[i]); } for (i = 0; data[i] >= 0; i++) { removeInt(hashtablePtr, &data[i]); assert(hashtable_find(hashtablePtr, &data[i]) == NULL); } hashtable_free(hashtablePtr); puts("Done."); return 0; }
static void destroy_pixel_hash(HashTable *hash) { PixelHashData *d=(PixelHashData *)hashtable_get_user_data(hash); if (d) free(d); hashtable_free(hash); }
void hdata_free (struct t_hdata *hdata) { if (hdata->hash_var) hashtable_free (hdata->hash_var); if (hdata->var_prev) free (hdata->var_prev); if (hdata->var_next) free (hdata->var_next); if (hdata->hash_list) hashtable_free (hdata->hash_list); if (hdata->name) free (hdata->name); free (hdata); }
void secure_free () { config_file_free (secure_config_file); if (secure_hashtable_data) { hashtable_free (secure_hashtable_data); secure_hashtable_data = NULL; } if (secure_hashtable_data_encrypted) { hashtable_free (secure_hashtable_data_encrypted); secure_hashtable_data_encrypted = NULL; } }
void parse(FileInfo *fi, Queue *queue, FILE *out) { // printf("parse()\n"); fflush(stdout); Parser parser; parser.tok_q = queue; parser.top = out; parser.fun_names = hashtable_create(TABLE_SZ); parser.classes = hashtable_create(TABLE_SZ); parser.fi_in = fi; parser.in_name = NULL; FILE *tmp = tmpfile(); //FILE *tmp = out; queue_init(&parser.classes_queue); parse_top_level(&parser, tmp); hashtable_free(parser.fun_names, do_nothing); void write_classes_and_del(void *comp_obj) { composite_class_save_src(parser.top, ((Object *) comp_obj)->comp); fprintf(parser.top, "\n"); // TODO //object_delete(comp_obj); }
static int map_image_pixels_from_quantized_pixels( Pixel *pixelData, uint32_t nPixels, Pixel *paletteData, uint32_t nPaletteEntries, uint32_t *avgDist, uint32_t **avgDistSortKey, uint32_t *pixelArray, uint32_t *avg[3], uint32_t *count) { uint32_t *aD,**aDSK; uint32_t idx; uint32_t i,j; uint32_t bestdist,bestmatch,dist; uint32_t initialdist; HashTable *h2; int changes=0; h2=hashtable_new(unshifted_pixel_hash,unshifted_pixel_cmp); for (i=0;i<nPixels;i++) { if (!hashtable_lookup(h2,pixelData[i],&bestmatch)) { bestmatch=pixelArray[i]; initialdist=_DISTSQR(paletteData+bestmatch,pixelData+i); bestdist=initialdist; initialdist<<=2; aDSK=avgDistSortKey+bestmatch*nPaletteEntries; aD=avgDist+bestmatch*nPaletteEntries; for (j=0;j<nPaletteEntries;j++) { idx=aDSK[j]-aD; if (*(aDSK[j])<=initialdist) { dist=_DISTSQR(paletteData+idx,pixelData+i); if (dist<bestdist) { bestdist=dist; bestmatch=idx; } } else { break; } } hashtable_insert(h2,pixelData[i],bestmatch); } if (pixelArray[i]!=bestmatch) { changes++; avg[0][bestmatch]+=pixelData[i].c.r; avg[1][bestmatch]+=pixelData[i].c.g; avg[2][bestmatch]+=pixelData[i].c.b; avg[0][pixelArray[i]]-=pixelData[i].c.r; avg[1][pixelArray[i]]-=pixelData[i].c.g; avg[2][pixelArray[i]]-=pixelData[i].c.b; count[bestmatch]++; count[pixelArray[i]]--; pixelArray[i]=bestmatch; } } hashtable_free(h2); return changes; }
void order_files (const char *dir, char **basenames, size_t n_basenames) { int dir_fd_open_flags; int dir_fd; struct statfs fs; size_t i; dir_fd_open_flags = O_SEARCH | O_DIRECTORY; #ifdef O_PATH dir_fd_open_flags |= O_PATH; #endif dir_fd = open (dir, dir_fd_open_flags); if (dir_fd < 0) return; if (fstatfs (dir_fd, &fs) < 0) { close (dir_fd); return; } /* Sort files by the physical locations of their first blocks, in an * attempt to minimise disk drive head movements. This assumes that * files are small enough that they are likely to be in one block or * a small number of contiguous blocks, which seems a reasonable * assumption for manual pages. */ physical_offsets = hashtable_create (plain_hashtable_free); for (i = 0; i < n_basenames; ++i) { struct { struct fiemap fiemap; struct fiemap_extent extent; } fm; int fd; fd = openat (dir_fd, basenames[i], O_RDONLY); if (fd < 0) continue; memset (&fm, 0, sizeof (fm)); fm.fiemap.fm_start = 0; fm.fiemap.fm_length = fs.f_bsize; fm.fiemap.fm_flags = 0; fm.fiemap.fm_extent_count = 1; if (ioctl (fd, FS_IOC_FIEMAP, (unsigned long) &fm) == 0) { uint64_t *offset = XMALLOC (uint64_t); *offset = fm.fiemap.fm_extents[0].fe_physical; hashtable_install (physical_offsets, basenames[i], strlen (basenames[i]), offset); } close (fd); } qsort (basenames, n_basenames, sizeof *basenames, compare_physical_offsets); hashtable_free (physical_offsets); physical_offsets = NULL; close (dir_fd); }
void hashtable_destroy(HashTable *table) { assert(table != NULL); hashtable_free(table); free(table); }
static void vchans_free(void) { hashtable_iterator_t iter = {0}; vchan_t *vchan = NULL; while((vchan = vchans_iterate(&iter))) { vchan_free(vchan); } hashtable_free(&vchans); }
void gui_nicklist_end () { if (gui_nicklist_hsignal) { hashtable_free (gui_nicklist_hsignal); gui_nicklist_hsignal = NULL; } }
int sgw_lite_cm_remove_bearer_context_information ( Teid_t teid) { int temp; temp = hashtable_free (sgw_app.s11_bearer_context_information_hashtable, teid); return temp; }
void eval_end () { if (eval_hashtable_pointers) { hashtable_free (eval_hashtable_pointers); eval_hashtable_pointers = NULL; } }
void ccplt_free(ccplt *lt) { for(ccpnode **c = lt->nodes; c < lt->nodes + lt->num_nodes; ++c) { ccpnode_free(*c); } free(lt->nodes); if(lt->ht) hashtable_free(lt->ht); if(lt->pred_num) predicate_numerator_free(lt->pred_num); free(lt); }
void secure_end () { if (secure_passphrase) { free (secure_passphrase); secure_passphrase = NULL; } if (secure_hashtable_data) { hashtable_free (secure_hashtable_data); secure_hashtable_data = NULL; } if (secure_hashtable_data_encrypted) { hashtable_free (secure_hashtable_data_encrypted); secure_hashtable_data_encrypted = NULL; } }
//----------------------------------------------------------------------------- int sgw_lite_cm_remove_s11_tunnel ( Teid_t local_teid) //----------------------------------------------------------------------------- { int temp; temp = hashtable_free (sgw_app.s11teid2mme_hashtable, local_teid); return temp; }
void gui_hotlist_end () { if (gui_hotlist_hashtable_add_conditions_pointers) { hashtable_free (gui_hotlist_hashtable_add_conditions_pointers); gui_hotlist_hashtable_add_conditions_pointers = NULL; } if (gui_hotlist_hashtable_add_conditions_vars) { hashtable_free (gui_hotlist_hashtable_add_conditions_vars); gui_hotlist_hashtable_add_conditions_vars = NULL; } if (gui_hotlist_hashtable_add_conditions_options) { hashtable_free (gui_hotlist_hashtable_add_conditions_options); gui_hotlist_hashtable_add_conditions_options = NULL; } }
static int map_image_pixels_from_median_box( Pixel *pixelData, uint32_t nPixels, Pixel *paletteData, uint32_t nPaletteEntries, HashTable *medianBoxHash, uint32_t *avgDist, uint32_t **avgDistSortKey, uint32_t *pixelArray) { uint32_t *aD,**aDSK; uint32_t idx; uint32_t i,j; uint32_t bestdist,bestmatch,dist; uint32_t initialdist; HashTable *h2; uint32_t pixelVal; h2=hashtable_new(unshifted_pixel_hash,unshifted_pixel_cmp); for (i=0;i<nPixels;i++) { if (hashtable_lookup(h2,pixelData[i],&pixelVal)) { pixelArray[i]=pixelVal; continue; } if (!hashtable_lookup(medianBoxHash,pixelData[i],&pixelVal)) { #ifndef NO_OUTPUT printf ("pixel lookup failed\n"); #endif return 0; } initialdist=_DISTSQR(paletteData+pixelVal,pixelData+i); bestdist=initialdist; bestmatch=pixelVal; initialdist<<=2; aDSK=avgDistSortKey+pixelVal*nPaletteEntries; aD=avgDist+pixelVal*nPaletteEntries; for (j=0;j<nPaletteEntries;j++) { idx=aDSK[j]-aD; if (*(aDSK[j])<=initialdist) { dist=_DISTSQR(paletteData+idx,pixelData+i); if (dist<bestdist) { bestdist=dist; bestmatch=idx; } } else { break; } } pixelArray[i]=bestmatch; hashtable_insert(h2,pixelData[i],bestmatch); } hashtable_free(h2); return 1; }
TEST(String, EvalPathHome) { char *home, *result; int length_home, length_weechat_home; struct t_hashtable *extra_vars; home = getenv ("HOME"); length_home = strlen (home); length_weechat_home = strlen (weechat_home); POINTERS_EQUAL(NULL, string_eval_path_home (NULL, NULL, NULL, NULL)); result = string_eval_path_home ("/tmp/test", NULL, NULL, NULL); STRCMP_EQUAL(result, "/tmp/test"); free (result); result = string_eval_path_home ("~/test", NULL, NULL, NULL); CHECK(strncmp (result, home, length_home) == 0); LONGS_EQUAL(length_home + 5, strlen (result)); STRCMP_EQUAL(result + length_home, "/test"); free (result); result = string_eval_path_home ("%h/test", NULL, NULL, NULL); CHECK(strncmp (result, weechat_home, length_weechat_home) == 0); LONGS_EQUAL(length_weechat_home + 5, strlen (result)); STRCMP_EQUAL(result + length_weechat_home, "/test"); free (result); setenv ("WEECHAT_TEST_PATH", "path1", 1); result = string_eval_path_home ("%h/${env:WEECHAT_TEST_PATH}/path2", NULL, NULL, NULL); CHECK(strncmp (result, weechat_home, length_weechat_home) == 0); LONGS_EQUAL(length_weechat_home + 12, strlen (result)); STRCMP_EQUAL(result + length_weechat_home, "/path1/path2"); free (result); extra_vars = hashtable_new (32, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING, NULL, NULL); CHECK(extra_vars); hashtable_set (extra_vars, "path2", "value"); result = string_eval_path_home ("%h/${env:WEECHAT_TEST_PATH}/${path2}", NULL, extra_vars, NULL); CHECK(strncmp (result, weechat_home, length_weechat_home) == 0); LONGS_EQUAL(length_weechat_home + 12, strlen (result)); STRCMP_EQUAL(result + length_weechat_home, "/path1/value"); free (result); hashtable_free (extra_vars); }
void sst_close(sstable_t* sst) { if (sst->status ==UNOPEN) { //TODO } else if (sst->status == COMPACT || sst->status == COMPACTED) { hashtable_free(sst->htable); } else if (sst->status != SNULL) { hashtable_relasedata(sst->htable); hashtable_free(sst->htable); } CloseHandle(sst->lock); xfree(sst); }
void script_closure_pred_equivalence_classes() { closure_operator *clop = clop_alloc_straightforward(); pred *ess_preds; size_t ess_sz; get_essential_predicates(2, &ess_preds, &ess_sz); /** We use a hash table to store a mapping between clones (equivalence * classes) and predicates that generate those clones (closure-equivalent * predicates). */ hashtable *ht = hashtable_alloc(512, clone_hash, (int (*)(const void *, const void *))clone_eq); /* construct the closure of all essential predicates */ for(pred *p = ess_preds; p < ess_preds + ess_sz; ++p) { clone *closure = aligned_alloc(32, sizeof(clone)); assert(closure); closure_one_pred(clop, p, closure); /* lookup equivalence class corresponding to `p` */ clone *equiv_preds = hashtable_lookup(ht, closure); if(equiv_preds == NULL) { equiv_preds = malloc(sizeof(clone)); assert(equiv_preds); clone_init(equiv_preds); hashtable_insert(ht, closure, equiv_preds); } else { free(closure); } clone_insert_pred(equiv_preds, p); } /* print the equivalence classes */ int idx = 1; for(hashtable_iterator it = hashtable_iterator_begin(ht); !hashtable_iterator_end(&it); hashtable_iterator_next(&it)) { hash_elem *elem = hashtable_iterator_deref(&it); printf("====== class %u ====================================\n", idx); for(clone_iterator itc = clone_iterator_begin((clone *)elem->value); !clone_iterator_end((clone *)elem->value, &itc); clone_iterator_next(&itc)) { pred p = clone_iterator_deref(&itc); printf("%s\t%s\n", pred_print_fingerprint(&p), pred_print_extensional_ex(&p)); } printf("\n"); free(elem->key); free(elem->value); ++idx; } hashtable_free(ht); free(ess_preds); clop_free(clop); }
void hdata_end () { hdata_free_all (); hashtable_free (dogechat_hdata); dogechat_hdata = NULL; if (hdata_search_pointers) { hashtable_free (hdata_search_pointers); hdata_search_pointers = NULL; } if (hdata_search_extra_vars) { hashtable_free (hdata_search_extra_vars); hdata_search_extra_vars = NULL; } if (hdata_search_options) { hashtable_free (hdata_search_options); hdata_search_options = NULL; } }
void piggy_close() { int i; custom_close(); piggy_close_file(); //added ifndef on 10/04/98 by Matt Mueller to fix crash on exit bug -- killed 2000/02/06 since they don't seem to cause crash anymore. heh. //#ifndef __LINUX__ if (BitmapBits) d_free(BitmapBits); if ( SoundBits ) d_free( SoundBits ); for (i = 0; i < Num_sound_files; i++) if (SoundOffset[i] == 0) d_free(GameSounds[i].data); //#endif //end addition -MM hashtable_free( &AllBitmapsNames ); hashtable_free( &AllDigiSndNames ); }
//----------------------------------------------------------------------------- int sgw_lite_cm_remove_eps_bearer_entry ( hash_table_t * eps_bearersP, ebi_t eps_bearer_idP) //----------------------------------------------------------------------------- { int temp; if (eps_bearersP == NULL) { return -1; } temp = hashtable_free (eps_bearersP, eps_bearer_idP); return temp; }
int secure_init () { int rc; char *ptr_phrase; /* try to read passphrase (if not set) from env var "WEECHAT_PASSPHRASE" */ if (!secure_passphrase) { ptr_phrase = getenv (SECURE_ENV_PASSPHRASE); if (ptr_phrase) { if (ptr_phrase[0]) secure_passphrase = strdup (ptr_phrase); unsetenv (SECURE_ENV_PASSPHRASE); } } secure_hashtable_data = hashtable_new (32, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING, NULL, NULL); if (!secure_hashtable_data) return 0; secure_hashtable_data_encrypted = hashtable_new (32, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING, NULL, NULL); if (!secure_hashtable_data_encrypted) { hashtable_free (secure_hashtable_data); return 0; } rc = secure_init_options (); if (!rc) { gui_chat_printf (NULL, _("FATAL: error initializing configuration options")); } return rc; }
static int map_image_pixels(Pixel *pixelData, uint32_t nPixels, Pixel *paletteData, uint32_t nPaletteEntries, uint32_t *avgDist, uint32_t **avgDistSortKey, uint32_t *pixelArray) { uint32_t *aD,**aDSK; uint32_t idx; uint32_t i,j; uint32_t bestdist,bestmatch,dist; uint32_t initialdist; HashTable *h2; h2=hashtable_new(unshifted_pixel_hash,unshifted_pixel_cmp); for (i=0;i<nPixels;i++) { if (!hashtable_lookup(h2,pixelData[i],&bestmatch)) { bestmatch=0; initialdist=_DISTSQR(paletteData+bestmatch,pixelData+i); bestdist=initialdist; initialdist<<=2; aDSK=avgDistSortKey+bestmatch*nPaletteEntries; aD=avgDist+bestmatch*nPaletteEntries; for (j=0;j<nPaletteEntries;j++) { idx=aDSK[j]-aD; if (*(aDSK[j])<=initialdist) { dist=_DISTSQR(paletteData+idx,pixelData+i); if (dist<bestdist) { bestdist=dist; bestmatch=idx; } } else { break; } } hashtable_insert(h2,pixelData[i],bestmatch); } pixelArray[i]=bestmatch; } hashtable_free(h2); return 1; }
/* ============================================================================= * sequencer_free * ============================================================================= */ void sequencer_free (sequencer_t* sequencerPtr) { long i; table_free(sequencerPtr->hashToConstructEntryTable); free(sequencerPtr->constructEntries); for (i = 1; i < sequencerPtr->segmentLength; i++) { table_free(sequencerPtr->startHashToConstructEntryTables[i]); } free(sequencerPtr->startHashToConstructEntryTables); free(sequencerPtr->endInfoEntries); hashtable_free(sequencerPtr->uniqueSegmentsPtr); if (sequencerPtr->sequence != NULL) { free(sequencerPtr->sequence); } free(sequencerPtr); }
/* ============================================================================= * sequencer_free * ============================================================================= */ void sequencer_free (sequencer_t* sequencerPtr) { long i; table_free(sequencerPtr->hashToConstructEntryTable); free(sequencerPtr->constructEntries); for (i = 1; i < sequencerPtr->segmentLength; i++) { table_free(sequencerPtr->startHashToConstructEntryTables[i]); } free(sequencerPtr->startHashToConstructEntryTables); free(sequencerPtr->endInfoEntries); #if 0 /* TODO: fix mixed sequential/parallel allocation */ hashtable_free(sequencerPtr->uniqueSegmentsPtr); if (sequencerPtr->sequence != NULL) { free(sequencerPtr->sequence); } #endif free(sequencerPtr); }
/* * Frees the resources that were allocated when the pattern was compiled. */ void tre_free_fast(fastmatch_t *fg) { DPRINT(("tre_fast_free: freeing structures for pattern %s\n", fg->pattern)); #ifdef TRE_WCHAR hashtable_free(fg->qsBc_table); if (!fg->hasdot) xfree(fg->bmGs); if (fg->wescmap) xfree(fg->wescmap); xfree(fg->wpattern); #endif if (!fg->hasdot) xfree(fg->sbmGs); if (fg->escmap) xfree(fg->escmap); xfree(fg->pattern); }