Glib hash table replace
Posted
by Robert
on Stack Overflow
See other posts from Stack Overflow
or by Robert
Published on 2010-02-16T03:24:26Z
Indexed on
2010/03/31
22:33 UTC
Read the original article
Hit count: 266
I'm using GLib Hash Table. I'm trying to get the current value of the key that I found and then increment its value. I'm not quite sure how can I replace the existing value.
typedef struct {
gchar *key;
guint my_int;
} my_struct;
char *v;
v = g_hash_table_lookup(table, my_struct.key);
if (v == NULL)
g_hash_table_insert(table, g_strdup(my_struct.key), (gpointer)(my_struct.my_int));
else
g_hash_table_replace() // here I'd like to do something like current_val+1
Any ideas will be appreciate it.
© Stack Overflow or respective owner