I've been searching around for a while to get an answer but I am still very unclear on what I am supposed to do.
In all the official examples all the Values and indexes and pointers to them are of the type Word_t or PWord_t, which as far as I can tell is just an int of some kind. My confusion is trying to understand how this can refer to a char* or buffer (char[]) or raw string ("string")
Here's something I've tried, but the output is unintelligible (like what you see when you print a binary)
#include <stdio.h>
#include <Judy.h>
int main()
{
Pvoid_t PJArray = (PWord_t)NULL; // Judy array.
PWord_t PValue; // Judy array element.
Word_t Bytes; // size of JudySL array.
JSLI(PValue, PJArray, "WHAT");
*PValue = "HELLO...";
JSLG(PValue, PJArray, "WHAT");
printf("%s\n", &PValue);
return 0;
}
output is:
`(@��
I ran your code thru my tool and it shows the code has a buffer overrun issue. This is the error msg:
Basically, &PValue takes the address of Pvalue and printf treats it as the address of a JudySL array of 4 bytes. If you change
to
It will print out "P{WHAT" for me. I'm not familiar with Judy hash, so you need to verify if it's the intended result.