mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-11 22:31:12 +02:00
* gc.c (scm_protect_object): Avoid looking up the object handle
twice. (scm_unprotect_object): Abort if scm_unprotect_object is called on an unprotected object.
This commit is contained in:
parent
2dd6a83aed
commit
0f0f08998d
1 changed files with 14 additions and 13 deletions
|
@ -2145,12 +2145,8 @@ scm_protect_object (SCM obj)
|
||||||
/* This critical section barrier will be replaced by a mutex. */
|
/* This critical section barrier will be replaced by a mutex. */
|
||||||
SCM_REDEFER_INTS;
|
SCM_REDEFER_INTS;
|
||||||
|
|
||||||
handle = scm_hashq_get_handle (scm_protects, obj);
|
handle = scm_hashq_create_handle_x (scm_protects, obj, SCM_MAKINUM (0));
|
||||||
|
SCM_SETCDR (handle, SCM_MAKINUM (SCM_INUM (SCM_CDR (handle)) + 1));
|
||||||
if (SCM_IMP (handle))
|
|
||||||
scm_hashq_create_handle_x (scm_protects, obj, SCM_MAKINUM (1));
|
|
||||||
else
|
|
||||||
SCM_SETCDR (handle, SCM_MAKINUM (SCM_INUM (SCM_CDR (handle)) + 1));
|
|
||||||
|
|
||||||
SCM_REALLOW_INTS;
|
SCM_REALLOW_INTS;
|
||||||
|
|
||||||
|
@ -2171,15 +2167,20 @@ scm_unprotect_object (SCM obj)
|
||||||
SCM_REDEFER_INTS;
|
SCM_REDEFER_INTS;
|
||||||
|
|
||||||
handle = scm_hashq_get_handle (scm_protects, obj);
|
handle = scm_hashq_get_handle (scm_protects, obj);
|
||||||
|
|
||||||
if (SCM_NIMP (handle))
|
if (SCM_IMP (handle))
|
||||||
{
|
{
|
||||||
int count = SCM_INUM (SCM_CDR (handle)) - 1;
|
fprintf (stderr, "scm_unprotect_object called on unprotected object\n");
|
||||||
if (count <= 0)
|
abort ();
|
||||||
scm_hashq_remove_x (scm_protects, obj);
|
|
||||||
else
|
|
||||||
SCM_SETCDR (handle, SCM_MAKINUM (count));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
int count = SCM_INUM (SCM_CDR (handle)) - 1;
|
||||||
|
if (count <= 0)
|
||||||
|
scm_hashq_remove_x (scm_protects, obj);
|
||||||
|
else
|
||||||
|
SCM_SETCDR (handle, SCM_MAKINUM (count));
|
||||||
|
}
|
||||||
|
|
||||||
SCM_REALLOW_INTS;
|
SCM_REALLOW_INTS;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue