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:
parent
b075a6d766
commit
ca33b501a9
1 changed files with 8 additions and 5 deletions
|
@ -190,9 +190,12 @@ which does the reverse. PRINT must name a user-defined object printer."
|
||||||
;; PTR1 == PTR2 <-> (eq? (wrap PTR1) (wrap PTR2)).
|
;; PTR1 == PTR2 <-> (eq? (wrap PTR1) (wrap PTR2)).
|
||||||
(let ((ptr->obj (make-weak-value-hash-table 3000)))
|
(let ((ptr->obj (make-weak-value-hash-table 3000)))
|
||||||
(lambda (ptr)
|
(lambda (ptr)
|
||||||
(let ((key+value (hash-create-handle! ptr->obj ptr #f)))
|
;; XXX: We can't use `hash-create-handle!' +
|
||||||
(or (cdr key+value)
|
;; `set-cdr!' here because the former would create a
|
||||||
(let ((o (%wrap ptr)))
|
;; weak-cdr pair but the latter wouldn't register a
|
||||||
(set-cdr! key+value o)
|
;; disappearing link (see `scm_hash_fn_set_x'.)
|
||||||
o))))))
|
(or (hash-ref ptr->obj ptr)
|
||||||
|
(let ((o (%wrap ptr)))
|
||||||
|
(hash-set! ptr->obj ptr o)
|
||||||
|
o)))))
|
||||||
(set-record-type-printer! type-name print)))))))
|
(set-record-type-printer! type-name print)))))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue