Re: [Fwd: [Kannel 0000077]: gwlib/dict.c seems to loose entries in the Dict structure]

Alexander Malysh <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Organization Centrium GmbH
Message-ID <[email protected]>
Hi Stipe,

i hope not ;)
It's pretty simple. You use in your test rand. The rand can not generate 
really unique keys. So if you key equal one which already stored in the dict 
, then old key will be overwritten with new one. Key _must_ be always unique.
Just try attached patch for ur test_dict.c...

On Monday 11 August 2003 14:22, Stipe Tolj wrote:
> Hi list,
>
> we seem to have a problem with our Dict (dictionary hash). When
> putting a lot of objects in there and lookin into how many we have, we
> get wrong results, see attached.
>
> Stipe
>
> [email protected]
> -------------------------------------------------------------------
> Wapme Systems AG
>
> Vogelsanger Weg 80
> 40470 Düsseldorf
>
> Tel: +49-211-74845-0
> Fax: +49-211-74845-299
>
> E-Mail: [email protected]
> Internet: http://www.wapme-systems.de
> -------------------------------------------------------------------
> wapme.net - wherever you are

-- 
Best regards / Mit besten Grüßen aus Düsseldorf

Dipl.-Ing.
Alexander Malysh
___________________________________________

Centrium GmbH
Vogelsanger Weg 80
40470 Düsseldorf

Fon: +49 (0211) 74 84 51 80
Fax: +49 (0211) 277 49 109

email: a.malysh at centrium.de
web: www.centrium.de
msn: olek2002 at hotmail.com
icq: 98063111
___________________________________________

Please avoid sending me Word or PowerPoint attachments.
See http://www.fsf.org/philosophy/no-word-attachments.html
test_dict.diff (text/x-diff, 852 B)
Index: test/test_dict.c
===================================================================
RCS file: /home/cvs/gateway/test/test_dict.c,v
retrieving revision 1.4
diff -a -u -r1.4 test_dict.c
--- test/test_dict.c	11 Aug 2003 11:49:32 -0000	1.4
+++ test/test_dict.c	11 Aug 2003 12:42:17 -0000
@@ -31,13 +31,13 @@
     dict_destroy(dict);
 
     debug("",0,"Dict extended/huge test.");
-    dict = dict_create(HUGE_SIZE, (void (*)(void *))octstr_destroy);
+    dict = dict_create(HUGE_SIZE*2, (void (*)(void *))octstr_destroy);
     for (i = 1; i <= HUGE_SIZE; i++) {
         unsigned long key, val;
         Octstr *okey, *oval;
         key = gw_rand();
         val = gw_rand();
-        okey = octstr_format("%ld", key);
+        okey = octstr_format("%ld", i);
         oval = octstr_format("%ld", val);
         dict_put(dict, okey, oval);
     }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.