/*================================================================= * finish_and_delete_nameset -- check for dups in a set of one name * soundexseq is sequence of NAMEs all in the same block (equivalent * names as far as NAME storage goes) * Created: 2001/01/13, Perry Rapp *===============================================================*/ static void finish_and_delete_nameset (void) { char prevkey[8]; CNSTRING name=""; CNSTRING skey=""; TABLE table = create_table_int(); prevkey[0]=0; calc_indiseq_names(soundexseq); keysort_indiseq(soundexseq); /* We go thru the list of equivalent names, sorted by person, and for each person, table all their names, watching for duplicates */ FORINDISEQ(soundexseq, el, num) name = element_sval(el); skey = element_skey(el); if (!eqstr(skey, prevkey)) { /* new person, start over */ destroy_table(table); table = create_table_int(); } if (in_table(table, name)) { report_error(ERR_DUPNAME, _("Duplicate name for %s (%s)") , skey, name); } else { insert_table_int(table, name, 1); } strcpy(prevkey, skey); ENDINDISEQ remove_indiseq(soundexseq); soundexseq = NULL; destroy_table(table); }
/*================================================================= * finish_and_delete_refnset -- check for dups in a set of one refn * soundexseq is sequence of REFNs all in the same block (equivalent * names as far as REFN storage goes) * Created: 2001/01/13, Perry Rapp *===============================================================*/ static void finish_and_delete_refnset (void) { char prevkey[8]; CNSTRING refn=""; CNSTRING skey=""; TABLE table = create_table_int(); prevkey[0]=0; canonkeysort_indiseq(soundexseq); FORINDISEQ(soundexseq, el, num) refn = element_sval(el); skey = element_skey(el); if (!eqstr(skey, prevkey)) { /* new person, start over */ destroy_table(table); table = create_table_int(); } if (in_table(table, refn)) { report_error(ERR_DUPREFN, _("Duplicate refn for %s (%s)") , skey, refn); } else { insert_table_int(table, refn, 1); } strcpy(prevkey, skey); ENDINDISEQ remove_indiseq(soundexseq); soundexseq = NULL; destroy_table(table); }
static double Expectation(DdNode **nodes_ex, int lenNodes) { int i; double rootProb, CLL = 0; for (i = 0; i < lenNodes; i++) { if (!Cudd_IsConstant(nodes_ex[i])) { nodesB = init_table(boolVars_ex[i]); nodesF = init_table(boolVars_ex[i]); Forward(nodes_ex[i], i); rootProb = GetOutsideExpe(nodes_ex[i], example_prob[i], i); if (rootProb <= 0.0) CLL = CLL + LOGZERO * example_prob[i]; else CLL = CLL + log(rootProb) * example_prob[i]; nodes_probs_ex[i] = rootProb; destroy_table(nodesB, boolVars_ex[i]); destroy_table(nodesF, boolVars_ex[i]); } else if (nodes_ex[i] == Cudd_ReadLogicZero(mgr_ex[i])) { CLL = CLL + LOGZERO * example_prob[i]; nodes_probs_ex[i] = 0.0; } else nodes_probs_ex[i] = 1.0; } return CLL; }
/*======================================== * lldb_close -- Close any database contained. * Free LLDATABASE structure. * Safe to call even if not opened *======================================*/ void lldb_close (LLDATABASE *plldb) { LLDATABASE lldb=0; ASSERT(plldb); lldb = *plldb; if (!lldb) return; if (tagtable) destroy_table(tagtable); tagtable = 0; /* TODO: reverse the rest of init_lifelines_postdb -- Perry, 2002.06.05 */ if (placabbvs) { destroy_table(placabbvs); placabbvs = NULL; } free_caches(); check_node_leaks(); check_record_leaks(); closexref(); ASSERT(BTR == lldb->btree); if (lldb->btree) { closebtree(lldb->btree); lldb->btree = 0; BTR = 0; } dbnotify_close(); transl_free_predefined_xlats(); /* clear any active legacy translation tables */ strfree(&readpath_file); strfree(&readpath); stdfree(lldb); *plldb = 0; }
static void __exit exit_tagfs_fs(void) { uninstall_syscalls(); destroy_table(table); printk("Unloading tagfs kernel module\n"); unregister_filesystem(&tagfs_fs_type); }
/* Trivial test provided by the instrucitonal staff*/ static int test1() { int table_size = 2; Table *table_ptr; create_table(&table_ptr, table_size, free); destroy_table(table_ptr); return SUCCESS; }
/*================================================= * release_table -- decrement reference count of table * and free if appropriate (ref count hits zero) *===============================================*/ void release_table (TABLE tab) { if (!tab) return; ASSERT(tab->vtable == &vtable_for_table); --tab->refcnt; if (!tab->refcnt) { destroy_table(tab); } }
/*=================================================== * free_proparray -- free array of property tables * NB: must have NULL marker entry at end * Created: 2002/10/19, Perry Rapp *=================================================*/ void free_proparray (TABLE ** props) { INT i; for (i=0; (*props)[i]; ++i) { TABLE tab = (*props)[i]; destroy_table(tab); } stdfree((*props)); *props = NULL; }
/** * Initializes the table for first use. */ void init_table(void) { junos_trace(PED_TRACEFLAG_HT, "%s", __func__); if(if_table) destroy_table(); if_table = create_hashtable(16, hashFromKey, equalKeys); INSIST(if_table != NULL); }
/*================================================== * create_database -- create (& open) brand new database * dbpath: [IN] path of database about to create *================================================*/ BOOLEAN create_database (STRING dbpath, INT *lldberr) { LLDATABASE lldb = lldb_alloc(); BTREE btree = 0; /* first test that newdb props are legal */ STRING props = getlloptstr("NewDbProps", 0); if (props && props[0]) { TABLE dbopts = create_table_str(); STRING msg=0; if (!init_valtab_from_string(props, dbopts, '=', &msg)) { *lldberr = BTERR_BADPROPS; destroy_table(dbopts); return FALSE; } destroy_table(dbopts); } /* tentatively copy paths into gedlib module versions */ readpath_file=strsave(lastpathname(dbpath)); readpath=strsave(dbpath); if (!(btree = bt_openbtree(dbpath, TRUE, 2, immutable, lldberr))) { /* open failed so clean up, preserve lldberr */ int myerr = *lldberr; lldb_close(&lldb); *lldberr = myerr; return FALSE; } def_lldb = lldb; lldb_set_btree(lldb, btree); initxref(); if (props) store_record("VUOPT", props, strlen(props)); return TRUE; }
int main() { Table *table_ptr; int x, y, table_size = 5; void *value; /***** Starting memory checking *****/ start_memory_check(); /***** Starting memory checking *****/ create_table(&table_ptr, table_size, NULL); x = 2; put(table_ptr, "Peggy", &x); y = 1; put(table_ptr, "John", &y); printf("Table size: %d\n", get_table_size(table_ptr)); if (is_empty(table_ptr)) { printf("Empty table\n"); } else { printf("Not empty\n"); } get_value(table_ptr, "John", &value); printf("Value for John %d\n", *(int *) value); printf("Removing Peggy: %d\n", remove_entry(table_ptr, "Peggy")); printf("Displaying Table\n"); display_table(table_ptr); clear_table(table_ptr); printf("After clearing\n"); if (is_empty(table_ptr)) { printf("Empty table\n"); } else { printf("Not empty\n"); } printf("Displaying Table\n"); display_table(table_ptr); destroy_table(table_ptr); /****** Gathering memory checking info *****/ stop_memory_check(); /****** Gathering memory checking info *****/ return 0; }
/*========================================= * check_btree -- Validate btree itself * Created: 2003/09/05, Perry Rapp *=======================================*/ static BOOLEAN check_btree (BTREE btr) { /* keep track of which files we've visited */ TABLE fkeytab = create_table_int(); /* check that master index has its fkey correct */ INDEX index = bmaster(BTR); INT mk1 = bkfile(btr).k_mkey; if (ixself(index) != mk1) { printf(_("Master fkey misaligned")); printf("(%ld != %ld\n", ixself(index), mk1); return FALSE; } check_index(btr, index, fkeytab, NULL, NULL); destroy_table(fkeytab); return TRUE; }
/*Test4 tests inserting a large number of keys, chekcing key_count, deleting a few, rechecking the key_count, then clearing the entire table. We will then reinsert some keys.*/ static int test4(){ int x = 1, y =2, z = 3, w =4, k = 5, a =6, b =7 , c =8, d = 9, e = 10, f = 11, g = 12; Table *t; /*Creates table and adds 13 keys to it.*/ create_table(&t, z, NULL); put(t, "Krabs", &a); put(t, "Larry", &b); put(t, "Herminator", &c); put(t, "Brian", &d); put(t, "Steve", &e); put(t, "Nelson", &f); put(t, "Corwin", &g); put(t, "Spongebob", &x); put(t, "Patrick", &y); put(t, "Squidward", &z); put(t, "Sandy", &w); put(t, "Art thou feeling it now,", NULL); put(t, "Mr. Krabs?", &k); printf("%d\n", get_key_count(t)); display_table(t); /*Removes two keys from the table, then rechekcs key_count and displays the state of the table.*/ remove_entry(t,"Mr. Krabs?"); remove_entry(t,"Art thou feeling it now,"); printf("%d\n", get_key_count(t)); display_table(t); /*Clears the table, then rechecks the key_count.*/ clear_table(t); printf("%d\n", get_key_count(t)); /*Reinserts 7 keys, then checks the state of the table again.*/ put(t, "A1", &a); put(t, "A2", &b); put(t, "A3", &c); put(t, "A4", &d); put(t, "A5", &e); put(t, "A6", &f); put(t, "A7", &g); display_table(t); destroy_table(t); return SUCCESS; }
static YAP_Bool ret_prob(void) { YAP_Term arg1, arg2, out; DdNode *node; arg1 = YAP_ARG1; arg2 = YAP_ARG2; node = (DdNode *)YAP_IntOfTerm(arg1); if (!Cudd_IsConstant(node)) { table = init_table(boolVars_ex[ex]); out = YAP_MkFloatTerm(Prob(node, 0)); destroy_table(table, boolVars_ex[ex]); } else { if (node == Cudd_ReadOne(mgr_ex[ex])) out = YAP_MkFloatTerm(1.0); else out = YAP_MkFloatTerm(0.0); } return (YAP_Unify(out, arg2)); }
/*================================================== * update_db_options -- * check database-specific options for updates *================================================*/ static void update_db_options (void) { TABLE opttab = create_table_str(); CNSTRING str=0; get_db_options(opttab); str = valueof_str(opttab, "codeset"); if (!str || !str[0]) { /* no specified database/internal codeset so default to user's default codeset, which should be from locale */ str = get_defcodeset(); } if (!int_codeset) strupdate(&int_codeset, ""); if (!eqstr_ex(int_codeset, str)) { /* database encoding changed */ strupdate(&int_codeset, str); /* Here is where the global uu8 variable is set This is a flag if the internal (database) encoding is UTF-8 */ uu8 = is_codeset_utf8(int_codeset); /* always translate to internal codeset */ set_gettext_codeset(PACKAGE, int_codeset); /* need to reload all predefined codeset conversions */ transl_load_xlats(); if (uu8) { charprops_load_utf8(); } else { charprops_load(int_codeset); } } destroy_table(opttab); }
static int compute_prob(void) /* this is the function that implements the compute_prob predicate used in pp.pl */ { YAP_Term out,arg1,arg2,arg3,arg4; variables vars; expr expression; DdNode * function; DdManager * mgr; int nBVar,i,intBits,create_dot; FILE * file; DdNode * array[1]; double prob; char * onames[1]; char inames[1000][20]; char * names[1000]; tablerow * nodes; arg1=YAP_ARG1; arg2=YAP_ARG2; arg3=YAP_ARG3; arg4=YAP_ARG4; mgr=Cudd_Init(0,0,CUDD_UNIQUE_SLOTS,CUDD_CACHE_SLOTS,0); create_dot=YAP_IntOfTerm(arg4); vars=createVars(arg1,mgr,create_dot,inames); //Cudd_PrintInfo(mgr,stderr); /* automatic variable reordering, default method CUDD_REORDER_SIFT used */ //printf("status %d\n",Cudd_ReorderingStatus(mgr,&order)); //printf("order %d\n",order); Cudd_AutodynEnable(mgr,CUDD_REORDER_SAME); /* Cudd_AutodynEnable(mgr, CUDD_REORDER_RANDOM_PIVOT); printf("status %d\n",Cudd_ReorderingStatus(mgr,&order)); printf("order %d\n",order); printf("%d",CUDD_REORDER_RANDOM_PIVOT); */ expression=createExpression(arg2); function=retFunction(mgr,expression,vars); /* the BDD build by retFunction is converted to an ADD (algebraic decision diagram) because it is easier to interpret and to print */ //add=Cudd_BddToAdd(mgr,function); //Cudd_PrintInfo(mgr,stderr); if (create_dot) /* if specified by the user, a dot file for the BDD is written to cpl.dot */ { nBVar=vars.nBVar; for(i=0; i<nBVar; i++) names[i]=inames[i]; array[0]=function; onames[0]="Out"; file = open_file("cpl.dot", "w"); Cudd_DumpDot(mgr,1,array,names,onames,file); fclose(file); } nodes=init_table(vars.nBVar); intBits=sizeof(unsigned int)*8; prob=Prob(function,vars,nodes); out=YAP_MkFloatTerm(prob); destroy_table(nodes,vars.nBVar); Cudd_Quit(mgr); for(i=0; i<vars.nVar; i++) { free(vars.varar[i].probabilities); free(vars.varar[i].booleanVars); } free(vars.varar); free(vars.bVar2mVar); for(i=0; i<expression.nTerms; i++) { free(expression.terms[i].factors); } free(expression.terms); return(YAP_Unify(out,arg3)); }
/*Tests inserting duplicate keys, and checks to see that the correct value is stored.*/ static int test5(){ int table_size = 4, x = 1, y = 3, z = 4, w = 5, delta = 20, p = 21, m = 22, a = 10, b = 2, c = 7, d = 8, e = 9, f = 12, g = 13; Table *t; void *value1, *value2, *value3, *value4, *value5, *value6, *value7, *value8, *value9, *value10, *value11, *value12, *value13, *value14; create_table(&t, table_size, NULL); /*Inserts 7 keys*/ put(t, "Krabs", &a); put(t, "Larry", &b); put(t, "Herminator", &c); put(t, "Brian", &d); put(t, "Steve", &e); put(t, "Nelson", &f); put(t, "Corwin", &g); /*Check that these keys have the correct values associated with them.*/ get_value(t, "Krabs", &value5); get_value(t, "Larry", &value6); get_value(t, "Herminator", &value7); get_value(t, "Brian", &value8); get_value(t, "Steve", &value9); get_value(t, "Nelson", &value10); get_value(t, "Corwin", &value11); printf("Value for Krabs: %d\n", *(int *) value5); printf("Value for Larry: %d\n", *(int *) value6); printf("Value for Herminator: %d\n", *(int *) value7); printf("Value for Brian: %d\n", *(int *) value8); printf("Value for Steve: %d\n", *(int *) value9); printf("Value for Nelson: %d\n", *(int *) value10); printf("Value for Corwin: %d\n", *(int *) value11); printf("\n"); /*Reinserts duplicates of the same seven keys*/ put(t, "Krabs", &x); put(t, "Larry", &y); put(t, "Herminator", &z); put(t, "Brian", &w); put(t, "Steve", &delta); put(t, "Nelson", &p); put(t, "Corwin", &m); /*Checks that the values now ewual to those given in the second insertion.*/ get_value(t, "Krabs", &value1); get_value(t, "Larry", &value2); get_value(t, "Herminator", &value3); get_value(t, "Brian", &value4); get_value(t, "Steve", &value12); get_value(t, "Nelson", &value13); get_value(t, "Corwin", &value14); printf("Value for Krabs: %d\n", *(int *) value1); printf("Value for Larry: %d\n", *(int *) value2); printf("Value for Herminator: %d\n", *(int *) value3); printf("Value for Brian: %d\n", *(int *) value4); printf("Value for Steve: %d\n", *(int *) value12); printf("Value for Nelson: %d\n", *(int *) value13); printf("Value for Corwin: %d\n", *(int *) value14); destroy_table(t); return SUCCESS; }
/*Tests null and failure cases for create_table, destroy_table, put, get_value, get_key_count*/ static int test3(){ int table_size =5, x =5; Table *t, *p; void *value1, *value2, *value3 = NULL; /*Tests NULL cases for create_table.*/ if(create_table(NULL, table_size, NULL ) != -1){ return FAILURE; }else if(create_table(&t, 0, NULL) != -1){ return FAILURE; }/*Tests NULL case for destroy_table.*/ if (destroy_table(NULL) != -1){ return FAILURE; }/*Tests NULL cases for put.*/ if (put(NULL, "Krabs", &x) != -1){ return FAILURE; }else if (put(t, NULL, &x) != -1){ return FAILURE; } /*Creates one empty table, and one table with two keys.*/ create_table(&t, table_size, NULL); create_table(&p, table_size, NULL); put(t, "Art thou feeling it now,", NULL); put(t, "Mr. Krabs?", &x); /*Tests NULL and FAILURE cases for get_value.*/ if(get_value(NULL, "Mr. Krabs?", &value1) != -1){ return FAILURE; } else if(get_value(t, NULL, &value1) != -1){ return FAILURE; } else if(get_value(t, "Spongebob", &value1) != -1){ return FAILURE; } /*Tests get_value for cases where the value stored is NULL and where the input parameter value is NULL. */ get_value(t, "Mr. Krabs?", &value1); get_value(t, "Art thou feeling it now,", &value2); get_value(t, "Mr. Krabs?", &value3); if(value2 != NULL){ return FAILURE; } printf("How much is Mr. Krabs feeling it: %d/10\n", *(int *) value1); printf("Key Count: %d\n", get_key_count(t)); /*Tests NULL case for get_key_count.*/ if(get_key_count(NULL) != -1){ return FAILURE; } /*Tests NULL and FAILURE cases for remove_entry.*/ if(remove_entry(NULL, "Mr. Krabs?") != -1){ return FAILURE; } else if (remove_entry(t, NULL) != -1){ return FAILURE; } else if (remove_entry(t, "Brian") != -1){ return FAILURE; } /*Tests NULL case for clear_table. */ if (clear_table(NULL) != -1){ return FAILURE; } /*Tests is_empty with NULL, empty, and non-empty table.*/ if (is_empty(t) != 0 || is_empty(NULL) != 1 || is_empty(p) != 1){ return FAILURE; } /*Tests NULL case of get_table_size.*/ if(get_table_size(NULL) != -1){ return FAILURE; } destroy_table(t); destroy_table(p); return SUCCESS; }
int main(int argc, char *argv[]) { /* MD settings */ N = 108; rho = 0.6; L = pow(N/rho, 1.0f/DIMENSION); double TEMP = 1.22; int total_steps = 11e4; /* allocate memory */ obj *particle = (obj*)malloc(N*sizeof(obj)); int **neighbour = NULL; neighbour = create_table(neighbour); init_pos(particle,N/2,0.0); init_pos(&particle[N/2],N-N/2,0.5); init_mom(particle); reset_mom(particle,TEMP/T); compute_table(particle,neighbour); get_acc(particle,neighbour); /* print header */ printf("#N=%d rho=%f L=%f T=%f dt=%f\n", N, rho, L, T, dt); printf("#\tt\tH\tU\tK\tT\n"); double sumU = 0.0f; double sumU2 = 0.0f; double sumT = 0.0f; double sumT2 = 0.0f; double sumP = 0.0f; double sumP2 = 0.0f; FILE *f = fopen("data/pressure.dat","w"); /* simulation run */ int i, count = 0; for(i = 0; i < total_steps; i++){ if(!(i%10)) compute_table(particle,neighbour); integrate(particle,neighbour); if((i*dt<10)&&(i%10==0)) reset_mom(particle,TEMP/T); if((i*dt>10)&&(i%100==0)){ sumU += U; sumU2 += U*U; sumT += T; sumT2 += T*T; /* pressure */ work = work/(DIMENSION*100*N*T)-1; sumP += work; sumP2 += work*work; fprintf(f,"%e\t%e\n",i*dt,work); work = 0.0f; count++; } printf("%e %e %e %e %e\n", i*dt, H/N, U/N, K/N, T ); } fclose(f); printf("# <U/N>=%e\tsqrt[<(U/N-<U/N>)²>]=%e\n", (sumU/count)/N, sqrt(sumU2/count-(sumU/count)*(sumU/count))/N ); printf("# <T>=%e\tsqrt[<(T-<T>)²>]=%e\n", (sumT/count), sqrt(sumT2/count-(sumT/count)*(sumT/count)) ); printf("# <P>=%e\tsqrt[<(P-<P>)²>]=%e\n", (sumP/count), sqrt(sumP2/count-(sumP/count)*(sumP/count)) ); /* exit */ free(particle); destroy_table(neighbour); return 0; }
int main() { void *data; char *command1, *command2, *def; int result; FILE *fp = fopen("hashlog.txt", "w"); CHTbl *htbl = malloc(sizeof(CHTbl)); chtbl_init(htbl, 4, g3, vstrcmp, NULL); fprintf(fp, "Load factor\tOccupancy\n", (float)(htbl->size/htbl->buckets), htbl->buckets); while(1) { printf(">"); command1 = malloc(sizeof(char)*10); command2 = malloc(sizeof(char)*50); def = malloc(sizeof(char)*1000); result = (parseline(command1, command2, def)); switch(result){ case -1: printf("Error: invalid use of 'add'\n"); free(command2); free(def); break; case -2: printf("Error: invalid use of 'delete'\n"); free(command2); free(def); break; case -3: printf("Error: invalid use of 'find'\n"); free(command2); free(def); break; case -4: printf("Error: command not recognized\n"); free(command2); free(def); break; case -5: printf("Error: no filename given"); free(command2); free(def); case 1: if(!(chtbl_insert(&htbl, command2, def))) { printf("Added %s to dictionary\n", command2); printtolog(fp, htbl); } else printf("Error - %s not added to dictionary\n", command2); break; case 2: free(def); if(!htbl_remove(htbl, command2)) { printf("Deleted %s from dictionary\n", command2); printtolog(fp, htbl); } else printf("Error - %s not found\n", command2); free(command2); break; case 3: free(def); if(!chtbl_lookup(htbl, command2, &data)) { printf("%s\n", command2); printf("%s\n", (char *)data); } else printf("%s not found in dictionary\n", command2); free(command2); break; case 4: free(command2); free(def); print_table(htbl); break; case 5: free(command1); free(command2); free(def); destroy_table(htbl); free(htbl); fclose(fp); return 0; break; case 6: if(!readfile(htbl, command2, fp)) printf("File scanned to dictionary\n"); else printf("Error - file not scanned\n"); free(command2); break; case 7: find2(htbl, command2, def); free(command2); free(def); break; case 8: ptest(htbl, command2, fp); break; } free(command1); } }
/*Tests creating a table, placing key/value pairs in it, getting values from the table, clearing the entire table, then reinserting some key/value pairs and getting their values. Also tests get_table_size */ static int test2() { int table_size = 4, x = 1, y = 3, z = 4, w = 5, a = 10, b = 2, c = 7, d = 8, e = 9, f = 12, g = 13; Table *t; void *value1, *value2, *value3, *value4, *value5, *value6, *value7, *value8, *value9, *value10, *value11; create_table(&t, table_size, NULL); /*Insert 4 keys into the table.*/ put(t, "Spongebob", &x); put(t, "Patrick", &y); put(t, "Squidward", &z); put(t, "Sandy", &w); /*Check that each key has the correct value, and that get_value is operating correctly.*/ get_value(t, "Spongebob", &value1); get_value(t, "Patrick", &value2); get_value(t, "Squidward", &value3); get_value(t, "Sandy", &value4); printf("Value for Spongebob: %d\n", *(int *) value1); printf("Value for Patrick: %d\n", *(int *) value2); printf("Value for Squidward: %d\n", *(int *) value3); printf("Value for Sandy: %d\n", *(int *) value4); printf("\n"); /*Check the State of the entire table.*/ display_table(t); /*Clear the entire table.*/ clear_table(t); /*Check that get_table_size and get_key_count are workign correctly.*/ if(get_table_size(t) != 4 || get_key_count(t) != 0){ return FAILURE; } /*Make sure the table is empty.*/ display_table(t); /*Reinsert 7 keys.*/ put(t, "Krabs", &a); put(t, "Larry", &b); put(t, "Herminator", &c); put(t, "Brian", &d); put(t, "Steve", &e); put(t, "Nelson", &f); put(t, "Corwin", &g); /*Check that these keys have the correct values associated witht hem.*/ get_value(t, "Krabs", &value5); get_value(t, "Larry", &value6); get_value(t, "Herminator", &value7); get_value(t, "Brian", &value8); get_value(t, "Steve", &value9); get_value(t, "Nelson", &value10); get_value(t, "Corwin", &value11); printf("Value for Krabs: %d\n", *(int *) value5); printf("Value for Larry: %d\n", *(int *) value6); printf("Value for Herminator: %d\n", *(int *) value7); printf("Value for Brian: %d\n", *(int *) value8); printf("Value for Steve: %d\n", *(int *) value9); printf("Value for Nelson: %d\n", *(int *) value10); printf("Value for Corwin: %d\n", *(int *) value11); /*Check the state of the entire table, especially to see if any keys from before clear_table was called are left over. */ display_table(t); printf("\n\n"); destroy_table(t); return SUCCESS; }
int cp_stage_1(cp_stage1* data, ruint_t* process_num) { int error = 0; *process_num = 0; proc_t* cp = get_current_process(); temp_proc_t* tp = malloc(sizeof(temp_proc_t)); if (tp == NULL) { goto handle_mem_error; } proc_t* process = malloc(sizeof(proc_t)); if (process == NULL) { goto handle_mem_error; } memset(process, 0, sizeof(proc_t)); tp->cstate = CP1; tp->process = process; process->__ob_lock = 0; process->process_list.data = process; if (data->privilege && cp->pprocess) process->pprocess = true; else process->pprocess = false; process->fds = create_array(); if (process->fds == NULL) { goto handle_mem_error; } process->threads = create_array(); if (process->fds == NULL) { destroy_array(process->fds); goto handle_mem_error; } process->mem_maps = NULL; process->proc_random = rg_create_random_generator(get_unix_time()); process->parent = NULL; if (data->parent) process->parent = cp; if (data->priority < 0) { process->priority = cp->priority; } else if (data->priority > 4) { error = EINVAL; goto handle_mem_error; } else process->priority = data->priority; process->futexes = create_uint64_table(); if (process->futexes == NULL) { error = ENOMEM_INTERNAL; goto handle_mem_error; } process->input_buffer = create_queue_static(__message_getter); if (process->input_buffer == NULL) { error = ENOMEM_INTERNAL; goto handle_mem_error; } process->pq_input_buffer = create_queue_static(__message_getter); if (process->input_buffer == NULL) { error = ENOMEM_INTERNAL; goto handle_mem_error; } process->blocked_wait_messages = create_list_static(__message_getter); if (process->blocked_wait_messages == NULL) { error = ENOMEM_INTERNAL; goto handle_mem_error; } process->temp_processes = create_list_static(__process_get_function); if (process->blocked_wait_messages == NULL) { error = ENOMEM_INTERNAL; goto handle_mem_error; } proc_spinlock_lock(&__proclist_lock); process->proc_id = ++process_id_num; proc_spinlock_unlock(&__proclist_lock); proc_spinlock_lock(&__proclist_lock2); if (table_set(temp_processes, (void*)process->proc_id, tp)) { proc_spinlock_unlock(&__proclist_lock2); error = ENOMEM_INTERNAL; goto handle_mem_error; } list_push_right(cp->temp_processes, process); proc_spinlock_unlock(&__proclist_lock2); return 0; handle_mem_error: if (tp != NULL) free(tp); if (process != NULL) { if (process->fds != NULL) destroy_array(process->fds); if (process->threads != NULL) destroy_array(process->threads); if (process->futexes != NULL) destroy_table(process->futexes); if (process->input_buffer != NULL) free_queue(process->input_buffer); if (process->pq_input_buffer != NULL) free_queue(process->pq_input_buffer); if (process->blocked_wait_messages != NULL) free_list(process->blocked_wait_messages); if (process->temp_processes != NULL) free_list(process->temp_processes); free(process); } return error; }
int create_process_base(uint8_t* image_data, int argc, char** argv, char** envp, proc_t** cpt, uint8_t asked_priority, registers_t* r) { proc_spinlock_lock(&__thread_modifier); uint8_t cpp = get_current_cput()->ct->parent_process->priority; proc_spinlock_unlock(&__thread_modifier); if (cpp > asked_priority) { return EINVAL; } int envc = 0; char** envt = envp; while (*envt != NULL) { ++envc; ++envt; } int err; if ((err = cpy_array(argc, &argv)) != 0) return err; if ((err = cpy_array(envc, &envp)) != 0) { free_array(argc, argv); return err; } // envp and argv are now kernel structures proc_t* process = malloc(sizeof(proc_t)); if (process == NULL) { return ENOMEM_INTERNAL; } memset(process, 0, sizeof(proc_t)); process->__ob_lock = 0; process->process_list.data = process; process->pprocess = true; process->fds = create_array(); if (process->fds == NULL) { free(process); return ENOMEM_INTERNAL; } process->threads = create_array(); if (process->fds == NULL) { destroy_array(process->fds); free(process); return ENOMEM_INTERNAL; } process->mem_maps = NULL; process->proc_random = rg_create_random_generator(get_unix_time()); process->parent = NULL; process->priority = asked_priority; process->pml4 = create_pml4(); if (process->pml4 == 0) { destroy_array(process->fds); free(process); return ENOMEM_INTERNAL; } process->futexes = create_uint64_table(); if (process->futexes == NULL) { destroy_array(process->threads); destroy_array(process->fds); free(process); return ENOMEM_INTERNAL; } process->input_buffer = create_queue_static(__message_getter); if (process->input_buffer == NULL) { destroy_table(process->futexes); destroy_array(process->threads); destroy_array(process->fds); free(process); return ENOMEM_INTERNAL; } process->pq_input_buffer = create_queue_static(__message_getter); if (process->input_buffer == NULL) { free_queue(process->input_buffer); destroy_table(process->futexes); destroy_array(process->threads); destroy_array(process->fds); free(process); return ENOMEM_INTERNAL; } process->blocked_wait_messages = create_list_static(__message_getter); if (process->blocked_wait_messages == NULL) { free_queue(process->pq_input_buffer); free_queue(process->input_buffer); destroy_table(process->futexes); destroy_array(process->threads); destroy_array(process->fds); free(process); return ENOMEM_INTERNAL; } process->temp_processes = create_list_static(__process_get_function); if (process->blocked_wait_messages == NULL) { free_list(process->blocked_wait_messages); free_queue(process->pq_input_buffer); free_queue(process->input_buffer); destroy_table(process->futexes); destroy_array(process->threads); destroy_array(process->fds); free(process); return ENOMEM_INTERNAL; } thread_t* main_thread = malloc(sizeof(thread_t)); if (main_thread == NULL) { free_list(process->temp_processes); free_list(process->blocked_wait_messages); free_queue(process->pq_input_buffer); free_queue(process->input_buffer); destroy_table(process->futexes); destroy_array(process->threads); destroy_array(process->fds); free(process); // TODO: free process address page return ENOMEM_INTERNAL; } memset(main_thread, 0, sizeof(thread_t)); main_thread->parent_process = process; main_thread->priority = asked_priority; main_thread->blocked = false; main_thread->continuation = malloc(sizeof(continuation_t)); if (main_thread->continuation == NULL) { free(main_thread); free_list(process->temp_processes); free_list(process->blocked_wait_messages); free_queue(process->pq_input_buffer); free_queue(process->input_buffer); destroy_table(process->futexes); destroy_array(process->threads); destroy_array(process->fds); free(process); // TODO: free process address page return ENOMEM_INTERNAL; } main_thread->continuation->present = false; main_thread->futex_block = create_list_static(__blocked_getter); if (main_thread->futex_block == NULL) { free(main_thread->continuation); free(main_thread); free_list(process->temp_processes); free_list(process->blocked_wait_messages); free_queue(process->pq_input_buffer); free_queue(process->input_buffer); destroy_table(process->futexes); destroy_array(process->threads); destroy_array(process->fds); free(process); // TODO: free process address page return ENOMEM_INTERNAL; } array_push_data(process->threads, main_thread); err = load_elf_exec((uintptr_t)image_data, process); if (err == ELF_ERROR_ENOMEM) { err = ENOMEM_INTERNAL; } else if (err != 0) { err = EINVAL; } if (err != 0) { free_list(main_thread->futex_block); free(main_thread->continuation); free(main_thread); free_list(process->temp_processes); free_list(process->blocked_wait_messages); free_queue(process->pq_input_buffer); free_queue(process->input_buffer); destroy_table(process->futexes); destroy_array(process->threads); destroy_array(process->fds); free(process); // TODO: free process address page return err; } char** argvu = argv; char** envpu = envp; if ((err = cpy_array_user(argc, &argvu, process)) != 0) { free_list(main_thread->futex_block); free(main_thread->continuation); free(main_thread); free_list(process->temp_processes); free_list(process->blocked_wait_messages); free_queue(process->pq_input_buffer); free_queue(process->input_buffer); destroy_table(process->futexes); destroy_array(process->threads); destroy_array(process->fds); free(process); // TODO: free process address page return err; } if ((err = cpy_array_user(envc, &envpu, process)) != 0) { free_list(main_thread->futex_block); free(main_thread->continuation); free(main_thread); free_list(process->temp_processes); free_list(process->blocked_wait_messages); free_queue(process->pq_input_buffer); free_queue(process->input_buffer); destroy_table(process->futexes); destroy_array(process->threads); destroy_array(process->fds); free(process); // TODO: free process address page return err; } main_thread->local_info = proc_alloc_direct(process, sizeof(tli_t)); if (main_thread->local_info == NULL) { free_list(main_thread->futex_block); free(main_thread->continuation); free(main_thread); free_list(process->temp_processes); free_list(process->blocked_wait_messages); free_queue(process->pq_input_buffer); free_queue(process->input_buffer); destroy_table(process->futexes); destroy_array(process->threads); destroy_array(process->fds); free(process); // TODO: free process address page return ENOMEM_INTERNAL; } tli_t* li = different_page_mem(process->pml4, main_thread->local_info); li->self = main_thread->local_info; for (int i=0; i<MESSAGE_BUFFER_CNT; i++) { _message_t* m = &process->output_buffer[i]; m->owner = process; m->used = false; m->message = proc_alloc_direct(process, 0x200000); if (m->message == NULL) { free_list(main_thread->futex_block); free(main_thread->continuation); free(main_thread); free_list(process->temp_processes); free_list(process->blocked_wait_messages); free_queue(process->pq_input_buffer); free_queue(process->input_buffer); destroy_table(process->futexes); destroy_array(process->threads); destroy_array(process->fds); free(process); // TODO: free process address page return ENOMEM_INTERNAL; } } process->argc = argc; process->argv = argvu; process->environ = envpu; main_thread->last_r12 = 0; main_thread->last_r11 = 0; main_thread->last_r10 = 0; main_thread->last_r9 = 0; main_thread->last_r8 = 0; main_thread->last_rax = 0; main_thread->last_rbx = 0; main_thread->last_rcx = 0; main_thread->last_rdx = 0; main_thread->last_rdi = 0; main_thread->last_rsi = 0; main_thread->last_rbp = 0; main_thread->last_rflags = 0x200; // enable interrupts proc_spinlock_lock(&__proclist_lock); main_thread->tId = __atomic_add_fetch(&thread_id_num, 1, __ATOMIC_SEQ_CST); process->proc_id = ++process_id_num; list_push_right(processes, process); proc_spinlock_unlock(&__proclist_lock); li->t = main_thread->tId; main_thread->last_rdi = (ruint_t)(uintptr_t)process->argc; main_thread->last_rsi = (ruint_t)(uintptr_t)process->argv; main_thread->last_rdx = (ruint_t)(uintptr_t)process->environ; main_thread->blocked_list.data = main_thread; main_thread->schedule_list.data = main_thread; free_array(argc, argv); free_array(envc, envp); // TODO: add split option? main_thread->last_rax = process->proc_id; enschedule_best(main_thread); *cpt = process; return 0; }
/*================================================= * table_destructor -- destructor for table * (destructor entry in vtable) *===============================================*/ static void table_destructor (VTABLE *obj) { TABLE tab = (TABLE)obj; destroy_table(tab); }
int main() { Tree *tree = createTree(); Hashtable *table5, *table50, *table500; FILE *fp50, *fp500, *fp5mil; clock_t tstart, tend; time_t t; srand((unsigned) time(&t)); double favg; int data = 0, i = 0, search, value, found; int array50k[50000], *array500k, *array5mil; array500k = malloc(500001 * sizeof(int)); array5mil = malloc(5000001 * sizeof(int)); if(tree == NULL) printf("Memory allocation failed..."); fp50 = fopen("50tus.txt", "r"); fp500 = fopen("500tus.txt", "r"); fp5mil = fopen("5mil.txt", "r"); if(fp50 == NULL || fp500 == NULL|| fp5mil == NULL) { fprintf(stderr, "error\n"); return 1; } system("color 3"); table5 = create_table(50000000); table50 = create_table(500000); table500 = create_table(5000000); /*50k*/ printf("\n50k insert, balance and search!\n"); printf("Insert: 50k "); tstart = clock(); // start for(i = 0; i < 50000; ++i) { fscanf(fp50,"%d\n", &data); insert(tree, data); } tend = clock(); // end favg = ((double)(tend - tstart))/CLOCKS_PER_SEC; printf("Avg. execution time: %g sec\n",favg); tree_to_arr(tree); printf("Searching 100x in 50k "); tstart = clock(); // start find_tree(tree); tend = clock(); // end favg = ((double)(tend - tstart))/CLOCKS_PER_SEC; printf("Avg. execution time: %g sec\n",favg); clear_tree(tree); /*500k*/ printf("\n500k insert, balance and search!\n"); printf("Insert: 500k "); tstart = clock(); // start for(i = 0; i < 500000; ++i) { fscanf(fp500,"%d\n", &data); insert(tree, data); } tend = clock(); // end favg = ((double)(tend - tstart))/CLOCKS_PER_SEC; printf("Avg. execution time: %g sec\n",favg); tree_to_arr(tree); printf("Searching 100x in 500k "); tstart = clock(); // start find_tree(tree); tend = clock(); // end favg = ((double)(tend - tstart))/CLOCKS_PER_SEC; printf("Avg. execution time: %g sec\n",favg); clear_tree(tree); /*5mille*/ printf("\n5 million insert, balance and search!\n"); printf("Insert: 5 million "); tstart = clock(); // start for(i = 0; i < 5000000; ++i) { fscanf(fp5mil,"%d\n", &data); insert(tree, data); } tend = clock(); // end favg = ((double)(tend - tstart))/CLOCKS_PER_SEC; printf("Avg. execution time: %g sec\n",favg); tree_to_arr(tree); printf("Searching 100x in 5 million "); tstart = clock(); // start find_tree(tree); tend = clock(); // end favg = ((double)(tend - tstart))/CLOCKS_PER_SEC; printf("Avg. execution time: %g sec\n",favg); clear_tree(tree); /*50k sekvens*/ printf("\nSekvential insert 50k!\n"); tstart = clock(); // start for(i = 0; i<50000; i++) { fscanf(fp50, "%d\n", &array50k[i]); } tend = clock(); // end favg = ((double)(tend - tstart))/CLOCKS_PER_SEC; printf("Avg. execution time: %g sec\n",favg); printf("Sekvential search 50k, 100x!\n"); tstart = clock(); // start for(i = 0; i<100; i++) { search = randomGen(); sekvential_search(array50k, search, 50000); } tend = clock(); // end favg = ((double)(tend - tstart))/CLOCKS_PER_SEC; printf("Avg. execution time: %g sec\n",favg); printf("Sekvential search 50k, 100x(o)!\n"); tstart = clock(); // start for(i = 0; i<100; i++) { search = randomGen(); sekvent_search(array50k, search, 50000); } tend = clock(); // end favg = ((double)(tend - tstart))/CLOCKS_PER_SEC; printf("Avg. execution time: %g sec\n",favg); /*500k sekvens*/ printf("\nSekvential insert 500k!\n"); tstart = clock(); // start for(i = 0; i<500000; i++) { fscanf(fp500, "%d\n", &array500k[i]); } tend = clock(); // end favg = ((double)(tend - tstart))/CLOCKS_PER_SEC; printf("Avg. execution time: %g sec\n",favg); printf("Sekvential search 500k, 100x!\n"); tstart = clock(); // start for(i = 0; i<100; i++) { search = randomGen(); sekvential_search(array500k, search, 500000); } tend = clock(); // end favg = ((double)(tend - tstart))/CLOCKS_PER_SEC; printf("Avg. execution time: %g sec\n",favg); printf("Sekvential search 500k, 100x(o)!\n"); tstart = clock(); // start for(i = 0; i<100; i++) { search = randomGen(); sekvent_search(array500k, search, 500000); } tend = clock(); // end favg = ((double)(tend - tstart))/CLOCKS_PER_SEC; printf("Avg. execution time: %g sec\n",favg); /*5mille seq*/ printf("\nSekvential insert 5 million!\n"); tstart = clock(); // start for(i = 0; i<5000000; i++) { fscanf(fp5mil, "%d\n", &array5mil[i]); } tend = clock(); // end favg = ((double)(tend - tstart))/CLOCKS_PER_SEC; printf("Avg. execution time: %g sec\n",favg); printf("Sekvential search 5 million, 100x!\n"); tstart = clock(); // start for(i = 0; i<100; i++) { search = randomGen(); sekvential_search(array5mil, search, 5000000); } tend = clock(); // end favg = ((double)(tend - tstart))/CLOCKS_PER_SEC; printf("Avg. execution time: %g sec\n",favg); printf("Sekvential search 5 million, 100x(o)!\n"); tstart = clock(); // start for(i = 0; i<100; i++) { search = randomGen(); sekvent_search(array5mil, search, 5000000); } tend = clock(); // end favg = ((double)(tend - tstart))/CLOCKS_PER_SEC; printf("Avg. execution time: %g sec\n",favg); /*Hash 500k*/ printf("\nHash insert 50k!\n"); tstart = clock(); // start for(i = 0; i<50000; i++){ fscanf(fp500, "%d\n", &value); insert_hash(table50, value); } tend = clock(); // end favg = ((double)(tend - tstart))/CLOCKS_PER_SEC; printf("Avg. execution time: %g sec\n",favg); /*Hash 500k*/ printf("\nHash insert 500k!\n"); tstart = clock(); // start for(i = 0; i<500000; i++){ fscanf(fp500, "%d\n", &value); insert_hash(table500, value); } tend = clock(); // end favg = ((double)(tend - tstart))/CLOCKS_PER_SEC; printf("Avg. execution time: %g sec\n",favg); /*Hash 5 mille*/ printf("\nHash insert 5 million!\n"); tstart = clock(); // start for(i = 0; i<5000000; i++){ fscanf(fp5mil, "%d\n", &value); insert_hash(table5, value); } tend = clock(); // end favg = ((double)(tend - tstart))/CLOCKS_PER_SEC; printf("Avg. execution time: %g sec\n",favg); destroy_table(table5); destroy_table(table50); destroy_table(table500); destroyTree(tree); return 0; }
/*================================================= * do_import -- Read GEDCOM file to database * ifeed: [IN] output methods * fp: [I/O] GEDCOM file whence to load data *===============================================*/ static BOOLEAN do_import (IMPORT_FEEDBACK ifeed, FILE *fp) { NODE node, conv; XLAT ttm = 0; STRING msg; BOOLEAN emp; INT nindi = 0, nfam = 0, neven = 0; INT nsour = 0, nothr = 0, type, num = 0; INT totkeys = 0, totused = 0; char msgbuf[80]; BOOLEAN succeeded=FALSE; STRING str,unistr=0; ZSTR zerr=0; TABLE metadatatab = create_table_str(); STRING gdcodeset=0; INT warnings=0; /* start by assuming default */ strupdate(&gdcodeset, gedcom_codeset_in); /* rptui_init(); *//* clear ui time counter */ /* Open and validate GEDCOM file */ if ((unistr=check_file_for_unicode(fp)) && !eqstr(unistr, "UTF-8")) { msg_error(_(qSunsupuniv), unistr); goto end_import; } if (eqstr_ex(unistr, "UTF-8")) { strupdate(&gdcodeset, "UTF-8"); } if (!scan_header(fp, metadatatab, &zerr)) { msg_error(zs_str(zerr)); goto end_import; } if ((str = valueof_str(metadatatab, "GEDC.FORM"))!= NULL) { if (!eqstr(str, "LINEAGE-LINKED")) { if (!ask_yes_or_no_msg( _("This is not a lineage linked GEDCOM file.") , _("Proceed anyway?") )) goto end_import; } } if (!unistr && (str = valueof_str(metadatatab, "CHAR"))!= NULL) { /* if no BOM, use file's declared encoding if present */ strupdate(&gdcodeset, str); } /* TODO: Push this codeset question down to after the validation, where we can know if the incoming file happened to really be all ASCII */ if (!int_codeset[0]) { /* TODO: ask if user would like to adopt codeset of incoming file, if we found it */ if (!ask_yes_or_no_msg( _("No current internal codeset, so no codeset conversion can be done") , _("Proceed without codeset conversion?") )) goto end_import; } /* Warn if lossy code conversion likely */ if (gdcodeset[0] && int_codeset[0]) { if (is_lossy_conversion(gdcodeset, int_codeset)) { ZSTR zstr=zs_new(); zs_setf(zstr, _("Lossy codeset conversion (from <%s> to <%s>) likely") , gdcodeset, int_codeset); if (!ask_yes_or_no_msg( zs_str(zstr) , _("Proceed anyway?") )) goto end_import; } } /* validate */ if (ifeed && ifeed->validating_fnc) (*ifeed->validating_fnc)(); if (!validate_gedcom(ifeed, fp)) { if (ifeed && ifeed->error_invalid_fnc) (*ifeed->error_invalid_fnc)(_(qSgdnadd)); goto end_import; } warnings = validate_get_warning_count(); if (warnings) { ZSTR zstr=zs_new(); zs_setf(zstr, _pl("%d warning during import", "%d warnings during import", warnings), warnings); if (!ask_yes_or_no_msg(zs_str(zstr), _(qSproceed))) { goto end_import; } } if (gdcodeset[0] && int_codeset[0]) { retry_input_codeset: ttm = transl_get_xlat(gdcodeset, int_codeset); if (!transl_is_xlat_valid(ttm)) { ZSTR zstr=zs_new(); char csname[64]; BOOLEAN b; transl_release_xlat(ttm); ttm = 0; zs_setf(zstr, _("Cannot convert codeset (from <%s> to <%s>)") , gdcodeset, int_codeset); b = ask_for_string(zs_str(zstr) , _("Enter codeset to assume (* for none)") , csname, sizeof(csname)) && csname[0]; zs_free(&zstr); if (!b) goto end_import; if (!eqstr(csname, "*")) { strupdate(&gdcodeset, csname); goto retry_input_codeset; } } } if((num_indis() > 0) || (num_fams() > 0) || (num_sours() > 0) || (num_evens() > 0) || (num_othrs() > 0)) gd_reuse = FALSE; else if((gd_reuse = check_stdkeys())) { totused = gd_itot + gd_ftot + gd_stot + gd_etot + gd_xtot; totkeys = gd_imax + gd_fmax + gd_smax + gd_emax + gd_xmax; if((totkeys-totused) > 0) { INT delkeys = totkeys-totused; snprintf(msgbuf, sizeof(msgbuf) , _pl("Using original keys, %d deleted record will be in the database." , "Using original keys, %d deleted records will be in the database." , delkeys) , delkeys ); } else strcpy(msgbuf, " "); gd_reuse = ask_yes_or_no_msg(msgbuf, _(qScfoldk)); /* TODO: why were these here ? touchwin(uiw_win(stdout_win)); wrefresh(uiw_win(stdout_win)); */ } /* start loading the file */ rewind(fp); /* test for read-only database here */ if(readonly) { if (ifeed && ifeed->error_readonly_fnc) (*ifeed->error_readonly_fnc)(); goto end_import; } /* tell user we are beginning real part of import */ if (ifeed && ifeed->beginning_import_fnc) { if(gd_reuse) (*ifeed->beginning_import_fnc)(_(qSdboldk)); else (*ifeed->beginning_import_fnc)(_(qSdbnewk)); } /* Add records to database */ node = convert_first_fp_to_node(fp, FALSE, ttm, &msg, &emp); while (node) { if (!(conv = node_to_node(node, &type))) { free_nodes(node); node = next_fp_to_node(fp, FALSE, ttm, &msg, &emp); continue; } switch (type) { case INDI_REC: num = ++nindi; break; case FAM_REC: num = ++nfam; break; case EVEN_REC: num = ++neven; break; case SOUR_REC: num = ++nsour; break; case OTHR_REC: num = ++nothr; break; default: FATAL(); } restore_record(conv, type, num); if (ifeed && ifeed->added_rec_fnc) ifeed->added_rec_fnc(nxref(conv)[1], ntag(conv), num); free_nodes(node); node = next_fp_to_node(fp, FALSE, ttm, &msg, &emp); } if (msg) { msg_error(msg); } if(gd_reuse && ((totkeys - totused) > 0)) { if (ifeed && ifeed->adding_unused_keys_fnc) (*ifeed->adding_unused_keys_fnc)(); addmissingkeys(INDI_REC); addmissingkeys(FAM_REC); addmissingkeys(EVEN_REC); addmissingkeys(SOUR_REC); addmissingkeys(OTHR_REC); } succeeded = TRUE; end_import: validate_end_import(); zs_free(&zerr); destroy_table(metadatatab); strfree(&gdcodeset); return succeeded; }