diff options
Diffstat (limited to 'src/emacs-module.c')
| -rw-r--r-- | src/emacs-module.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/emacs-module.c b/src/emacs-module.c index 7b1a402eeff..ad6c8fb0104 100644 --- a/src/emacs-module.c +++ b/src/emacs-module.c @@ -315,20 +315,18 @@ module_free_global_ref (emacs_env *env, emacs_value ref) MODULE_FUNCTION_BEGIN (); struct Lisp_Hash_Table *h = XHASH_TABLE (Vmodule_refs_hash); Lisp_Object obj = value_to_lisp (ref); - EMACS_UINT hashcode; - ptrdiff_t i = hash_lookup (h, obj, &hashcode); + ptrdiff_t i = hash_lookup (h, obj, NULL); if (i >= 0) { - Lisp_Object value = HASH_VALUE (h, i); - EMACS_INT refcount = XFASTINT (value) - 1; + EMACS_INT refcount = XFASTINT (HASH_VALUE (h, i)) - 1; if (refcount > 0) + set_hash_value_slot (h, i, make_natnum (refcount)); + else { - value = make_natnum (refcount); - set_hash_value_slot (h, i, value); + eassert (refcount == 0); + hash_remove_from_table (h, obj); } - else - hash_remove_from_table (h, value); } if (module_assertions) @@ -817,9 +815,13 @@ in_current_thread (void) static void module_assert_thread (void) { - if (! module_assertions || in_current_thread ()) + if (!module_assertions) return; - module_abort ("Module function called from outside the current Lisp thread"); + if (!in_current_thread ()) + module_abort ("Module function called from outside " + "the current Lisp thread"); + if (gc_in_progress) + module_abort ("Module function called during garbage collection"); } static void |
