RE: GHashTable insertion problems (string literals, c_str(), etc.)

Hi Christer,

No particular reason - its just when I searched "Vector" and "HashTable" in
Google, glib / GTK+ came up first. 

I tried using STL for insertions as well, but I came up with the same
c_str() "addressing" problem. The issue seems to be that when I insert with
a .c_str() into the hash table (both gtk's and STL's) it records the
address(?). It seems like if I pass in a "string literal", it works. Is
there some way, glib can convert variables into string literals? 

I do notice there is a "g_string(x)" macro but I'm not sure how to use it.

Thank you.


-----Original Message-----
From: Christer Palm [mailto:palm nogui se] 
Sent: Wednesday, April 14, 2004 3:32 AM
To: edwardt
Cc: gtk-list gnome org
Subject: Re: GHashTable insertion problems (string literals, c_str(), etc.)

Hi Edward!
Is there a particular reason to why you, as a C++ programmer, want to 
use GTK+ and glib? IMHO, you should probably use STL and gtkmm. In that 
way you'd avoid many problems like this.

edwardt wrote:
> Is there anyway I can store in / GHashTable takes in strings as **string 
> literals** ? The issue I come across when after I insert two of these 
> types of objects, and I run g_hash_table_foreach(), then the loop keeps 
> on repeating itself infinitely,  I believe because of something due to 
> using c_str() as the key.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]