vhash_status_t vhash_rebuild_table( vhash_t * v, unsigned long table_size) { unsigned long i; unsigned long old_size = v->table_size; vhash_node_t * old_table = v->table; if(table_size < v->count) table_size = v->count; v->table_size = get_power_of_2_size(table_size); v->table = (vhash_node_t *) v->malloc(sizeof(vhash_node_t) * table_size); memset(v->table, 0, sizeof(vhash_node_t)*v->table_size); v->count=0; for(i=0; i<old_size; i++) if(old_table[i].state == NODE_STATE_IN_USE) vhash_insert_item(v, (void*) old_table[i].key, old_table[i].item); v->free(old_table); return VHASH_STATUS_SUCCESS; }
void vhash_insert( vhash_t * v, void * in_key, void * item) { vhash_insert_item(v, in_key, item); }
vhash_status_t vhash_insert_string_key_item( vhash_t * v, const char * string, void * item) { V_POINTER_SIZED_INT key = vhash_char_key(v, string); /*build up string node*/ vhash_string_node_t * sn = (vhash_string_node_t *) v->malloc(sizeof(vhash_string_node_t)); sn->item = item; sn->string = (char *) v->malloc(strlen(string)+1); strcpy(sn->string, string); return vhash_insert_item(v, (void*) key, (void*) sn); }
vhash_status_t vhash_replace_item( vhash_t * v, void * in_key, void * new_item, void ** replaced_item) { void * item = 0; vhash_status_t status = VHASH_STATUS_INSERTED; if(vhash_remove_item(v, in_key, &item)){ if(replaced_item) *replaced_item=item; status = VHASH_STATUS_SUCCESS; } vhash_insert_item(v, in_key, new_item); return status; }
EE_LIST* HSolidModel::GetEEListForComponent(component_handle* comp_handle) { EE_LIST* ret_eelist = 0; if( !mhash_CompHandle_2_EEList ) mhash_CompHandle_2_EEList = new_vhash(512, malloc, free); if( VHASH_STATUS_SUCCESS != vhash_lookup_item(mhash_CompHandle_2_EEList, comp_handle, (void**) &ret_eelist) ) { // create a EE_LIST of ASM_MODEL_REFs outcome o; asm_model* root_model = 0; entity_handle_list model_refs; o = asmi_component_get_root_model(comp_handle, root_model); o = asmi_component_get_path(comp_handle, root_model, model_refs); // #ifdef DEBUG_NEW // #undef new DEBUG_NEW ret_eelist = ACIS_NEW EE_LIST(); // #define new DEBUG_NEW // #endif ret_eelist->set_ownership(false); ret_eelist->init(); model_refs.init(); for (entity_handle* ent_handle = model_refs.first(); ent_handle != NULL; ent_handle = model_refs.next()) { ENTITY* ent = ent_handle->entity_ptr(); ret_eelist->add(ent); } vhash_insert_item(mhash_CompHandle_2_EEList, (void*) comp_handle, (void*)ret_eelist); } return ret_eelist; }