On 20/05/2009, at 9:26 PM, Schaeferhaus wrote:
>
> A proposal of a new (simpler? better?) Judy-arrays API.
> Hier an example for JudyL functions.
> -----------------------------------------------------------------------
Unfortunately, you can't make a safe interface in C.
In C++ you can do better, in Felix it is possible to do it properly.
It's easy to make mistakes ..
>
> #include <Judy.h>
>
> struct judy_s { Pcvoid_t *judy; };
> typedef struct judy_s judy;
> typedef Word_t value_t; // or typedef uintptr_t value_t; /*32/64
> bits-value*/
>
> judy *judynew() { return NULL; }
this won't work so well because below you write judy->judy and that
fails if the first judy there is NULL.
instead you should just do the same cast you do on the next line ..
except ..
>
> value_t *judylins(judy *judy, value_t x) { return (Word_t
> *)JudyLIns((PPvoid_t)judy, x, NULL); }
This cast isn't legal is it? You cannot cast a * to a struct to a
void** directly. You would
need to write
(void**)(void*)judy
first casting to void*. BTW: the use of aliases like PPvoid_t is a bad
idea IMHO.
What does it mean? Have to look it up. Why typedef something as simple
as void**? Better to spell it out.
>
> value_t *judyldel(judy *judy, value_t x) { return (Word_t
> *)JudyLDel((PPvoid_t)judy, x, NULL); }
>
> void judyldestroy(judy *judy) { JudyLFreeArray((PPvoid_t)judy,
> NULL); }
>
> value_t *judylget(judy *judy, value_t x) { return (Word_t
> *)JudyLGet(judy->judy, x, NULL); }
>
--
john skaller
[email protected]
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables
unlimited royalty-free distribution of the report engine
for externally facing server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Judy-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/judy-devel