/** * librdf_finish_uri: * @world: redland world object * * INTERNAL - Terminate the uri module. * **/ void librdf_finish_uri(librdf_world *world) { if (world->uris_hash) { librdf_hash_close(world->uris_hash); if(world->uris_hash_allocated_here) librdf_free_hash(world->uris_hash); } }
/** * librdf_finish_uri: * @world: redland world object * * INTERNAL - Terminate the uri module. * **/ void librdf_finish_uri(librdf_world *world) { #ifndef LIBRDF_USE_RAPTOR_URI if (world->uris_hash) { librdf_hash_close(world->uris_hash); if(world->uris_hash_allocated_here) librdf_free_hash(world->uris_hash); } #endif }
static void test_all(const char *program) { librdf_hash *h; int num_test_hash_types, i, j; //const char *test_hash_types[]={"bdb", "tokyodb", "memory", NULL}; const char *test_hash_types[]={"tokyodb"}; librdf_world *world; world=librdf_new_world(); librdf_world_open(world); num_test_hash_types = sizeof(test_hash_types)/sizeof(const char*); for(i=0; i < num_test_hash_types; i++) { char db_name[100]; const char *type = test_hash_types[i]; fprintf(stdout, "Trying to create new %s hash\n", type); h=librdf_new_hash(world, type); if(!h) { fprintf(stderr, "Failed to create new hash type '%s' '%s'\n", program, type); continue; } sprintf(db_name, "test_%s_%s", type, DB_NAME_SUFFIX); if(librdf_hash_open(h, db_name, 0644, 1, 1, NULL)) { fprintf(stderr, "Failed to open new hash type '%s' '%s'\n", program, type); continue; } for (j=1; j<=STRESS_TEST_HASH_ITERATION; j++) { fprintf(stdout, "test_hash_funtionality iteration.. %d\n", j); test_hash_funtionality(world, h); } librdf_hash_close(h); fprintf(stdout, "Freeing hash: %s\n", program); librdf_free_hash(h); } librdf_free_world(world); }
static int test_hash_funtionality(librdf_world *world, librdf_hash *h) { librdf_hash *ch; const char *test_put_array[]={ "colour","yellow", "age", "new", "size", "large", "colour", "green", "fruit", "banana", "colour", "yellow", }; const char *test_delete_array[]={ "invalidkey", "invalidvalue", "colour", "yellow", "colour", "aaaaaaaaaaaaainvalidvalue", "colour", "zzzzzzzzzzzzzinvalidvalue", "colour", NULL, "fruit", NULL, "size", "large", "age", "new", }; const char *test_get_values_for_key="colour"; int len, i; for (i=1; i<=STRESS_TEST_PUT_ITERATION; i++) { fprintf(stdout, "put iteration.. %d\n", i); /* Test put */ len = sizeof(test_put_array)/sizeof(const char*); test_put(world, h, test_put_array, len); } fprintf(stdout, "total values: %d.", librdf_hash_values_count(h)); /* Test get all keys only */ fprintf(stdout, "all hash keys:"); librdf_hash_print_keys(h, stdout); fputc('\n', stdout); /* Test get all values of given key */ fprintf(stdout, "all values of key '%s'=", test_get_values_for_key); librdf_hash_print_values(h, test_get_values_for_key, stdout); fputc('\n', stdout); /* Test cloning hash */ fprintf(stdout, "cloning hash\n"); ch = librdf_new_hash_from_hash(h); if(ch) { fprintf(stdout, "clone success. values count %d\n", librdf_hash_values_count(ch)); fprintf(stdout, "resulting: "); librdf_hash_print(ch, stdout); fputc('\n', stdout); librdf_hash_close(ch); librdf_free_hash(ch); } else { fprintf(stderr, "Failed to clone hash\n"); } /* Test delete */ len = sizeof(test_delete_array)/sizeof(const char*); test_delete(world, h, test_delete_array, len); /* Test string related features */ test_string_manipulation(world, h); return 0; }