I'm having one hell of a time trying to figure out how to detect
when JudyL routines got an error or not.
It seems JudyLGet can return BOTH PPJERR and NULL independently,
indeed JudyLFirst contains this code:
PPvoid_t PValue;
if ((PValue = JudyLGet(PArray, *PIndex, PJError)) == PPJERR)
return(PPJERR);
if (PValue != (PPvoid_t) NULL) return(PValue); // found *PIndex.
return(JudyLNext(PArray, PIndex, PJError));
[BAD .. never call the public interface of a routine inside
any routine at the same level! Doing so makes it impossible
to wrap the public interface without interfering with the
implementation]
The problem is I'm getting BOTH conditions returned to a client
and it is just nonsense to have to test both PPJERR and NULL.
Logically, JudyLGet should return a pointer to the value
slot, or NULL if the key doesn't exist. No error is possible
on any of the JudyL reading routines: only JudyLIns/Del can
possibly have an error (because they're the only ones that
allocate memory, and memory allocation failure is the only
error Judy can possible have).
Corrupted Judy structure should instantly abort().
If you have corruption, you need the earliest possible core dump.
BTW: using ~0UL is a bad idea. This is NOT -1 on XP64, because
long is only 4 bytes, and when cast to 8 bytes it may lead to
0x0000_0000_FFFF_FFFF
which is not what you wanted .. depending on how the cast is done.
If you cast to 'long long = Word_t' first, you'll get all FF bytes,
but if you cast to void* first, you'll only get a half word.
In any case, only JudyLIns/Del can legitimately return such a code,
and it always means 'out of memory', in which case NULL would do.
That is: NULL is the only publicly required error code for JudyL,
and -1 for Judy1.
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Judy-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/judy-devel