gemstone/tests/glib/glib_hashmap.c

28 lines
501 B
C
Raw Normal View History

2024-05-18 10:25:13 +00:00
#include <glib.h>
int main(int argc, char* argv[]) {
GHashTable* map = g_hash_table_new(g_str_hash, g_str_equal);
for (int i = 0; i < argc; i++) {
int* index = malloc(sizeof(int));
*index = i;
2024-05-18 12:05:12 +00:00
g_hash_table_insert(map, argv[i], index);
2024-05-18 10:25:13 +00:00
}
for (int i = 0; i < argc; i++) {
int* index = (int*) g_hash_table_lookup(map, argv[i]);
g_hash_table_remove(map, argv[i]);
free(index);
}
g_hash_table_destroy(map);
return 0;
}