Matthew:
NO,  you are not using Judy correctly.  I think you are being deceived by the 
macrosJ1S and JLI.   They call JudyLIns(&storage, ..) and 
Judy1Set(&newPair,..);  Noticethat "storage" and "newPair" etc.  are actually 
pointers to the pointer to the actual Judy arrays.The contents of newPair and 
storage change as the Judy array grows.  When you setnewPair and storage to 
NULL, you are destroying the pointers to the actual Judy arrays.After setting 
them to NULL, and then do a J1S() or JLI(), you are actually creatinga new Judy 
Arrays and abandoning the old ones.  I miss comments describing whatyou are 
trying to accomplish.  Good Luck.

I hope that helps
 Doug Baskins <[email protected]> 

   

 On Saturday, November 18, 2017 11:15 AM, Matthew Brown <[email protected]> 
wrote:
 

 Dear Judy Masters,
I am having trouble with the following program that uses Judy Arrays. I know 
the program appears to be an inefficient method to achieve a certain goal, but 
it is the simplest program that demonstrates my problem. I would be very 
grateful if someone could take a look at what I am doing wrong.
The problem is essentially this: stepping through the program with the debugger 
causes the counter variable to follow the sequence 0,1,2,1.
Rather, I am expecting the sequence to be 0,1,2,3 by the successive addition of 
a new entry to the relevant J1 Array.
I am using icc to compile both Judy and the sample program.
Thank you very muchMatthew

#include <stdio.h>#include <stdlib.h>
#include "Judy.h"
int main(void){
printf("Hello Everyone");
int Rc_int;
Word_t *PValue;
Word_t Value;
Pvoid_t PArray;
Pvoid_t Ref;
Pvoid_t newPair;
Pvoid_t storage;
//A counter variableWord_t counter=0;
newPair = (Pvoid_t) NULL;
J1S(Rc_int, newPair, 1);J1S(Rc_int, newPair, 2);
PArray = (Pvoid_t) NULL;
J1S(Rc_int, PArray, (Word_t)newPair);
storage = (Pvoid_t) NULL;
JLI(PValue, storage, 2);*PValue = (Word_t)PArray;
JLG(PValue, storage, 2);Value = *PValue;
Ref = (Pvoid_t)Value;
J1C(counter, Ref, 0, -1);
newPair = (Pvoid_t)NULL;
J1S(Rc_int, newPair, 3);J1S(Rc_int, newPair, 4);
JLG(PValue, storage, 2);Value = *PValue;
PArray = (Pvoid_t)Value;J1S(Rc_int, PArray, (Word_t)newPair);
JLG(PValue, storage, 2);Value = *PValue;
Ref = (Pvoid_t)Value;
J1C(counter, Ref, 0, -1);
newPair = (Pvoid_t) NULL;
J1S(Rc_int, newPair, 5);J1S(Rc_int, newPair, 6);
JLG(PValue, storage, 2);Value = *PValue;
PArray = (Pvoid_t)Value;J1S(Rc_int, PArray, (Word_t)newPair);
JLG(PValue, storage, 2);Value = *PValue;
Ref = (Pvoid_t)Value;
J1C(counter, Ref, 0, -1);
return 0;
}------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! 
http://sdm.link/slashdot_______________________________________________
Judy-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/judy-devel


   
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Judy-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/judy-devel

Reply via email to