[Pkg-vala-maintainers] Bug#543249: Bug#543249: Bug#543249: Getting an item from a HashMap always results in NULL.

Sebastian Dröge slomo at circular-chaos.org
Mon Aug 24 09:24:04 UTC 2009


Am Sonntag, den 23.08.2009, 20:26 +0200 schrieb Sebastian Dröge:
> forwarded 543249 http://bugzilla.gnome.org/show_bug.cgi?id=592817
> thanks
> 
> Am Sonntag, den 23.08.2009, 17:28 +0200 schrieb Julian Andres Klode:
> > Package: libgee1
> > Version: 0.3.0-1
> > Severity: important
> > 
> > If I use HashMap.get() in the Vala program, it returns null. The
> > attached Vala code can be used to reproduce the bug.
> 
> Thanks, I've forwarded this bug upstream

Btw, you should do:

new Gee.HashMap<string,string>(GLib.str_hash, GLib.str_equal,
GLib.str_equal);

Without specifying comparision/hash functions for the hashmap the direct
hash/comparision functions are used which simply compare pointers. For
string keys you don't want to compare pointers unless they're quarks or
something like that (but then you would use GQuark as key I guess).

The specific problem here is, that the hashmap internally strdups your
string keys which generates a new pointer. And then the key changes ;)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
URL: <http://lists.alioth.debian.org/pipermail/pkg-vala-maintainers/attachments/20090824/5b6dc2b3/attachment.pgp>


More information about the Pkg-vala-maintainers mailing list