Commits

evhan committed 2725fed

set finalizer on oids produced by oid-cpy

  • Participants
  • Parent commits ff70b6b

Comments (0)

Files changed (1)

File git-lolevel.scm

 
 (define oid-fromstr      (foreign-lambda/allocate oid git_oid_fromstr nonnull-c-string))
 (define oid-shorten-add  (foreign-lambda/retval git_oid_shorten_add oid-shorten nonnull-c-string))
-(define oid-cpy          (foreign-lambda void git_oid_cpy oid oid))
 (define oid-cmp          (foreign-lambda int git_oid_cmp oid oid))
 (define oid-ncmp         (foreign-lambda int git_oid_ncmp oid oid unsigned-int))
 (define oid-equal        (foreign-lambda bool git_oid_equal oid oid))
 (define oid-shorten-free (foreign-lambda void git_oid_shorten_free oid-shorten))
 (define oid-allocfmt     (foreign-lambda c-string git_oid_allocfmt oid))
 
+(define (oid-cpy oid1)
+  (let ((oid2 (make-oid)))
+    ((foreign-lambda void git_oid_cpy oid oid) oid2 oid1)
+    (set-finalizer! oid2 oid-free)))
+
 (define (oid-fmt oid)
   (let ((str (make-string 40)))
     ((foreign-lambda void git_oid_fmt scheme-pointer oid) str oid)