1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-29 22:40:34 +02:00

Work around weak-value hash table bug in `define-wrapped-pointer-type'.

* module/system/foreign.scm (define-wrapped-pointer-type)[wrap]: Use
  `hash-ref' and `hash-set!' instead of `hash-create-handle!' and
  `set-cdr!'.
This commit is contained in:
Ludovic Courtès 2011-03-13 16:09:55 +01:00
parent b075a6d766
commit ca33b501a9

View file

@ -190,9 +190,12 @@ which does the reverse. PRINT must name a user-defined object printer."
;; PTR1 == PTR2 <-> (eq? (wrap PTR1) (wrap PTR2)).
(let ((ptr->obj (make-weak-value-hash-table 3000)))
(lambda (ptr)
(let ((key+value (hash-create-handle! ptr->obj ptr #f)))
(or (cdr key+value)
;; XXX: We can't use `hash-create-handle!' +
;; `set-cdr!' here because the former would create a
;; weak-cdr pair but the latter wouldn't register a
;; disappearing link (see `scm_hash_fn_set_x'.)
(or (hash-ref ptr->obj ptr)
(let ((o (%wrap ptr)))
(set-cdr! key+value o)
o))))))
(hash-set! ptr->obj ptr o)
o)))))
(set-record-type-printer! type-name print)))))))