1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00

fix scm_object_property_set_x for handles and weak tables

* libguile/objprop.c (scm_object_property_set_x): Use ref and set!
  instead of create-handle and set-cdr!, as it is a weak hash table.
  (scm_set_object_properties_x): Likewise.
This commit is contained in:
Andy Wingo 2011-05-01 21:00:54 +02:00
parent 4466db75da
commit 1ad9fdb727

View file

@ -1,4 +1,4 @@
/* Copyright (C) 1995,1996, 2000, 2001, 2003, 2006, 2008, 2009, 2010 Free Software Foundation, Inc. /* Copyright (C) 1995,1996, 2000, 2001, 2003, 2006, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
@ -59,11 +59,8 @@ SCM_DEFINE (scm_set_object_properties_x, "set-object-properties!", 2, 0, 0,
"Set @var{obj}'s property list to @var{alist}.") "Set @var{obj}'s property list to @var{alist}.")
#define FUNC_NAME s_scm_set_object_properties_x #define FUNC_NAME s_scm_set_object_properties_x
{ {
SCM handle;
scm_i_pthread_mutex_lock (&whash_mutex); scm_i_pthread_mutex_lock (&whash_mutex);
handle = scm_hashq_create_handle_x (object_whash, obj, alist); scm_hashq_set_x (object_whash, obj, alist);
SCM_SETCDR (handle, alist);
scm_i_pthread_mutex_unlock (&whash_mutex); scm_i_pthread_mutex_unlock (&whash_mutex);
return alist; return alist;
@ -87,19 +84,16 @@ SCM_DEFINE (scm_set_object_property_x, "set-object-property!", 3, 0, 0,
"to @var{value}.") "to @var{value}.")
#define FUNC_NAME s_scm_set_object_property_x #define FUNC_NAME s_scm_set_object_property_x
{ {
SCM h; SCM alist;
SCM assoc; SCM assoc;
scm_i_pthread_mutex_lock (&whash_mutex); scm_i_pthread_mutex_lock (&whash_mutex);
h = scm_hashq_create_handle_x (object_whash, obj, SCM_EOL); alist = scm_hashq_ref (object_whash, obj, SCM_EOL);
assoc = scm_assq (key, SCM_CDR (h)); assoc = scm_assq (key, alist);
if (SCM_NIMP (assoc)) if (SCM_NIMP (assoc))
SCM_SETCDR (assoc, value); SCM_SETCDR (assoc, value);
else else
{ scm_hashq_set_x (object_whash, obj, scm_acons (key, value, alist));
assoc = scm_acons (key, value, SCM_CDR (h));
SCM_SETCDR (h, assoc);
}
scm_i_pthread_mutex_unlock (&whash_mutex); scm_i_pthread_mutex_unlock (&whash_mutex);
return value; return value;