GHashTable * grn_test_pat_get_pairs(grn_ctx *context, grn_obj *patricia_trie) { GList *node, *ordered_pairs; GHashTable *pairs; grn_table_cursor *cursor; cursor = grn_table_cursor_open(context, patricia_trie, NULL, 0, NULL, 0, 0, -1, GRN_CURSOR_ASCENDING); ordered_pairs = grn_test_pat_cursor_get_pairs(context, cursor); grn_table_cursor_close(context, cursor); pairs = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); for (node = ordered_pairs; node; node = g_list_next(node)) { gchar *key, *value; key = node->data; node = g_list_next(node); if (!node) break; value = node->data; g_hash_table_insert(pairs, key, value); } g_list_free(ordered_pairs); return pairs; }
static GList * retrieve_all_keys_and_values(void) { keys_and_values_free(); keys_and_values = grn_test_pat_cursor_get_pairs(context, (grn_table_cursor *)cursor); return keys_and_values; }