Re: Glib hash table - unkown key in table
- From: David Nečas <yeti physics muni cz>
- To: Ervin Hegedüs <airween gmail com>
- Cc: gtk-list gnome org
- Subject: Re: Glib hash table - unkown key in table
- Date: Sun, 23 Mar 2014 19:52:11 +0100
On Sun, Mar 23, 2014 at 07:09:41PM +0100, Ervin Hegedüs wrote:
int utype_inc(char udatakey[15], int udata) {
...
g_hash_table_insert(datastore, udatakey, utype_rec_udatas);
This is certainly wrong. The string key must exist during the lifetime
of the hash table, so stack storage won't do it. You need to allocate
the string on the heap (or use GStringChunk, quarks or whatever). Using
g_hash_table_new_full() and passing a free-function can take care of
clean up when the table is destroyed.
Regards,
Yeti
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]