summaryrefslogtreecommitdiff
path: root/src/emacs-module.c
diff options
context:
space:
mode:
authorMichael R. Mauger <michael@mauger.com>2017-07-24 22:15:04 -0400
committerMichael R. Mauger <michael@mauger.com>2017-07-24 22:15:04 -0400
commitdf1a71272e5cdd10b511e2ffd702ca50ddd8a773 (patch)
tree9b9ac725394ee80891e2bff57b6407d0e491e71a /src/emacs-module.c
parenteb27fc4d49e8c914cd0e6a8a2d02159601542141 (diff)
parent32daa3cb54523006c88717cbeac87964cd687a1b (diff)
downloademacs-df1a71272e5cdd10b511e2ffd702ca50ddd8a773.tar.gz
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
Diffstat (limited to 'src/emacs-module.c')
-rw-r--r--src/emacs-module.c22
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