static void hash_table_destroy_nodes(struct hash_table *table) { unsigned int i; for (i = 0; i < table->size; i++) { if (table->nodes[i].next != NULL) destroy_node_list(table, table->nodes[i].next); } }
float jpcnn_predict(void* predictorHandle, float* predictions, int predictionsLength) { SPredictorInfo* predictorInfo = (SPredictorInfo*)(predictorHandle); struct svm_model* model = predictorInfo->model; struct svm_node* nodes = create_node_list(predictions, predictionsLength); double probabilityEstimates[2]; svm_predict_probability(model, nodes, probabilityEstimates); const double predictionValue = probabilityEstimates[0]; destroy_node_list(nodes); return predictionValue; }
void hash_table_destroy(struct hash_table **_table) { struct hash_table *table = *_table; *_table = NULL; if (!table->node_pool->alloconly_pool) { hash_table_destroy_nodes(table); destroy_node_list(table, table->free_nodes); } p_free(table->table_pool, table->nodes); p_free(table->table_pool, table); }
void hash_table_clear(struct hash_table *table, bool free_nodes) { if (!table->node_pool->alloconly_pool) hash_table_destroy_nodes(table); if (free_nodes) { if (!table->node_pool->alloconly_pool) destroy_node_list(table, table->free_nodes); table->free_nodes = NULL; } memset(table->nodes, 0, sizeof(struct hash_node) * table->size); table->nodes_count = 0; table->removed_count = 0; }
int main (void) { List *f; List *t; IOString src_name; IOString src_version; IOString src_type; IOString tgt_name; IOString tgt_version; IOString tgt_type; gap_set_if_vectors(1); printf("Covert Project Database\nVersion 1.4, 28th May 1997\n"); #define NUMBER(A) ((int)(sizeof(A) / sizeof((A)[0]))) get_db("Please enter database to convert:\n",src_types, NUMBER(src_types), src_name, src_version, src_type); get_db("Please enter database to create:\n",tgt_types, NUMBER(tgt_types), tgt_name, tgt_version, tgt_type); if (strcmp(src_type,tgt_type)==0) crash("Cannot convert a database to another of the same type\n"); f = build_list ( atom_str(db_from), build_list( atom_str(db_name), atom_str(src_name), nil), build_list( atom_str(db_version), atom_str(src_version), nil), build_list( atom_str(db_type), atom_str(src_type), nil), nil); t = build_list ( atom_str(db_to), build_list( atom_str(db_name), atom_str(tgt_name), nil), build_list( atom_str(db_version), atom_str(tgt_version), nil), build_list( atom_str(db_type), atom_str(tgt_type), nil), nil); process (f,t); destroy_list(f); destroy_list(t); destroy_node_list(); /* garbage collect */ printf("\nConversion completed\n"); return 0; }