[vox-tech] stupid hash doesn't work with libglib-2.0

Brian Lavender brian at brie.com
Sat Feb 13 17:36:34 PST 2010


I figured it out! When I created the hash with g_hash_table_new_full,
I provided NULL as the hash function. I changed this to g_int_hash,
a built in function in glib that hashes a pointer to an integer.

I almost wonder if I wrote my own hash if it would have been faster? 

I also found a decent article on IBM regarding glib.
http://www.ibm.com/developerworks/linux/library/l-glib2.html

brian


On Fri, Feb 12, 2010 at 12:24:10AM -0800, Brian Lavender wrote:
> I am trying to eliminate duplicates, so I figured I would just use a
> hash from libglib-2.0. It worked fine with static pointers (or whatever
> you call that portion oof code)
> 
> Problem is, once I try it with dynamically allocated pointers, it
> doesn't eliminiate any duplicates. 
> 
> Anything obvious that I am missing?
> 
> Comple with the following.
> 
> gcc `pkg-config glib-2.0 --cflags` read_hash.c -o read_hash
> 

-- 
Brian Lavender
http://www.brie.com/brian/

"About 3 million computers get sold every year in China, but people don't
pay for the software. Someday they will, though. As long as they are going
to steal it, we want them to steal ours. They'll get sort of addicted, and
then we'll somehow figure out how to collect sometime in the next decade."

-- Bill Gates (Microsoft) 1998
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hashtest3.c
Type: text/x-csrc
Size: 2229 bytes
Desc: not available
Url : http://lists.lugod.org/pipermail/vox-tech/attachments/20100213/0751618a/attachment.c 
-------------- next part --------------
334
1
4
56
32
12
1
4
56
56
12


More information about the vox-tech mailing list