On 25/10/2012, at 2:35 AM, Tim Margheim wrote:

> Thanks.  John's answer fixes the crashing loop.  I still have the access 
> violation in 64-bit mode when populating the tree, though.

Repost your code with the fix.
Do you know which call causes the access violation, i.e. exactly where?

Does Valgrind run on windows?
if you have a commercial Visual Studio it has some kind of
similar debugging functionality.


> At any rate, PValue is an lvalue, isn't it?  So I still need to figure out 
> why it works properly in 32-bit, but hits an access violation in 64-bit.  Or 
> am I missing something?

It's hard to tell, what kind of access violation?
Is it an alignment problem or reference to unallocated memory?

> How large should I make the buffer?  Is there a maximum size that Judy has 
> for a key value--and I should use that?  Or should I define my own maximum 
> size for keys on my tree, and use that?

Judy has no limits (apart from the size of a machine word :)

To do it right you either define your own maximum, and enforce it
when setting keys, or, you track the actual maximum used.

> If I'd payed closer attention to the function parameters, I could have 
> figured it out.

That's why you should use the raw C interface.
Judy is *logical*. FWIIW here's my Felix binding of JudySL:


  proc free: JSLArray = "_jSLfree(NULL,$1);" requires jSLfree;

  const JUDY_SL_MAXLEN : int = "JUDY_SL_MAXLEN";

  proc JudySLIns: JSLArray * +char * &JError_t * &&word =
    """
      if (::std::strlen($2) >= JUDY_SL_MAXLEN) throw "JudySLIns strlen>10000";
      *(Word_t**)$4=(Word_t*)JudySLIns($1,(unsigned char*)$2,$3);
    """;

  proc JudySLDel: JSLArray * +char * &JError_t * &int =
    "*$4=JudySLDel($1,(unsigned char*)$2,$3);";

  proc JudySLGet: JSLArray * +char * &JError_t * &&word =
    "*$4=(Word_t*)JudySLGet(*$1,(unsigned char*)$2,$3);";

  proc JudySLFirst: JSLArray * +char * &JError_t * &&word =
    "*(Word_t**)$4=(Word_t*)JudySLFirst(*$1,(unsigned char*)$2,$3);";

  proc JudySLNext: JSLArray * +char * &JError_t * &&word =
    "*(Word_t**)$4=(Word_t*)JudySLNext(*$1,(unsigned char*)$2,$3);";

  proc JudySLLast: JSLArray * +char * &JError_t * &&word =
    "*$4=JudySLLast(*$1,(unsigned char*)$2,$3);";

  proc JudySLPrev: JSLArray * +char * &JError_t * &&word =
    "*$4=JudySLPrev(*$1,(unsigned char*)$2,$3);";


This is used to make a high level string keyed dictionary type,
here's one of the methods:

   //$ Get an optional value with key greater than or equal to
   //$ the supplied NTBS (unsafe!)
   gen charp_get_ge (x:strdict) (var key: +char) : opt[T]= {
     var err: JError_t;
     var slot : && T; 
     JudySLFirst (_repr_ x, key, &err, C_hack::cast[&&word] (&slot));
     if C_hack::isNULL slot do 
       return None[T];
     else
       return Some (**slot);
     done
   }

   //$ Get an optional value with key greater than or equal to
   //$ the supplied string. Safer than the NTBS version but slower. 
   //$ Fails if the string contains a nul byte.
   fun get_ge (x:strdict) (var key: string)= {
     var err: JError_t;
     var slot : && T; 
     var k = array_alloc[char]$ JUDY_SL_MAXLEN+1; 
     strncpy (k,key.cstr, JUDY_SL_MAXLEN);
     var result = charp_get_ge x k;
     match result with
     | Some ?v =>
       key = k.string;
       free k; 
       return Some (key,v);
     | None=>
       free k;
       return None[string * T];
     endmatch ;
   }


--
john skaller
[email protected]
http://felix-lang.org




------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Judy-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/judy-devel

Reply via email to