Just Launched: You can now import projects and releases from Google Code onto SourceForge
We are excited to release new functionality to enable a 1-click import from Google Code onto the Allura platform on SourceForge. You can import tickets, wikis, source, releases, and more with a few simple steps. Read More
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:
if ((PValue = JudyLGet(PArray, *PIndex, PJError)) == 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
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
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