On 20/05/2009, at 3:24 AM, Alan Silverstein wrote: > > And you must say *PV = (Word_t) val, not PV = (PWord_t) val. You are > putting a value through a pointer. The fact that val itself is a > pointer is not important here. You have this backwards, don't store > your pointer in JudySL's pointer, store your pointer as a word UNDER > the > JudySL pointer to value word.
This is another case where the use of MACROS really confuses things. I strongly recommend NOT using the macros because they just add confusion about lvalues to an already type-unsafe interface. The raw C interface to Judy is tricky to understand but it is exactly right once you figure out the semantics. The type unsafety is a problem of C not Judy. Compiling with C++ doesn't help, because generally you need even more casts to force things into place. Here's some conceptual help: 1. Judy arrays are represented by pointers, a NULL is an empty array. It is the client's responsibility to store the array in a *single* variable. The semantics are confusing because pointers pass by value but Judy arrays are objects NOT values. 2. Judy search functions usually require a pointer to the location into which the key is stored and a pointer to the location into which the pointer to the value is stored. That's a bit confusing but entirely logical. After a search, you have a pointer to the value directly in the array, so you can either fetch it or modify it. Note your variable contains this pointer into the array not the value itself. you had to give Judy a pointer to the variable so it could store there.. so if you happen to be storing pointers in the array that's a pointer to a pointer to a pointer supplied to Judy as an argument. Keys require a pointer to the location the key will be store in. However in a couple of cases, there's a difference, and keys are passed directly by value. This saves one indirection without losing any functionality. If you understand the semantics it is easier to get the interface calls right. Everything is eminently logical given the weakness of the C type system. -- 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
