Hi felix, Thanks a lot for your modification. The new version works fine, except for the case of fetching non-existent data. (it crashes)
My patch is the following, but I hope you have another way, maybe? Daishi --- gdbm.scm.felix 2005-07-14 09:56:33.000000000 +0900 +++ gdbm.scm 2005-07-14 10:31:01.000000000 +0900 @@ -119,7 +119,7 @@ (lp (gdbm-next-key dbf key) (kons key val acc)))))) (define-external (make_string_with_len (c-pointer ptr) (int len)) scheme-object - (and (not (##sys#null-pointer? ptr)) + (and ptr (let ([str (make-string len)]) (##core#inline "copy_string_result" ptr len str) (##core#inline "free_ptr" ptr) At Wed, 13 Jul 2005 23:29:01 +0200, felix winkelmann wrote: > > [1 <text/plain; ISO-8859-1 (quoted-printable)>] > On 7/5/05, Daishi Kato <[EMAIL PROTECTED]> wrote: > > Hi, > > > > As looking into the gdbm egg, I noticed the limitation > > that it can only handle strings without any zeros in the middle, > > in other words, "c-string"s. > > Attached file is the patch for it, > > although the function "make_string_with_len" is not nice. > > I'm not sure if it works correctly, > > since I'm not familiar with the GC stuff. > > I believe there should be some kind of low-level function > > doing the similar thing, which can improve this patch. > > > > Many thanks for your patch. I've optimized the string-construction > procedure a little (the way you handle this is correct, there is currently > no way of heap-allocating storage from the GC'd heap without > doing a callback), and replaced some foreign-lambda forms with > foreign-safe-lambda (otherwise really weird crashes happen when > you call back the string-constructor). I also checked out the gdbm > manpages and they require to free(3) the results of `gdbm_fetch', etc. > I've attached the new version. I plan to release a new chicken version > soon, and since many things have changed, the improved gdbm egg > will be made publicly available at the same time (but this one should > work fine with the current chicken). > > > cheers, > felix > [2 gdbm.scm <application/octet-stream (base64)>] > _______________________________________________ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users