summaryrefslogtreecommitdiff
path: root/src/emacs-module.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2015-11-21 10:38:19 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2015-11-21 10:44:04 -0800
commit8afaa1321f8088bfb877fe4b6676e8517adb0bb7 (patch)
tree7e865f4b42fc44ba38abf7d0188db0aa05096fbd /src/emacs-module.c
parentd696d62fea48096680d6d511a71c4df56d00a51f (diff)
downloademacs-8afaa1321f8088bfb877fe4b6676e8517adb0bb7.tar.gz
Add a few safety checks when ENABLE_CHECKING
This was motivated by the recent addition of module code, which added some ENABLE_CHECKING-enabled checks that are useful elsewhere too. * src/alloc.c (compact_font_cache_entry): * src/fns.c (sweep_weak_table): * src/lread.c (oblookup): Use gc_asize rather than doing it by hand. * src/emacs-module.c (module_make_global_ref) (module_free_global_ref, module_vec_size): Omit assertions that lisp.h now checks. * src/lisp.h (XFASTINT, ASIZE): In functional implementations, check that the result is nonnegative. Use eassume, as this info can help a bit when optimizing production code. (XSYMBOL) [!USE_LSB_TAG]: Assert that argument is a symbol, to be consistent with the USE_LSB_TAG case. (gc_asize): New function, when ASIZE is needed in the gc. (gc_aset): Use it. (HASH_TABLE_P): Move definition up, so that it can be used ... (XHASH_TABLE): ... here, to assert that the arg is a hash table.
Diffstat (limited to 'src/emacs-module.c')
-rw-r--r--src/emacs-module.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/src/emacs-module.c b/src/emacs-module.c
index 011cc7be914..c8a0d89492a 100644
--- a/src/emacs-module.c
+++ b/src/emacs-module.c
@@ -257,7 +257,6 @@ module_make_global_ref (emacs_env *env, emacs_value ref)
check_main_thread ();
eassert (module_non_local_exit_check (env) == emacs_funcall_exit_return);
MODULE_HANDLE_SIGNALS;
- eassert (HASH_TABLE_P (Vmodule_refs_hash));
struct Lisp_Hash_Table *h = XHASH_TABLE (Vmodule_refs_hash);
Lisp_Object new_obj = value_to_lisp (ref);
EMACS_UINT hashcode;
@@ -266,7 +265,6 @@ module_make_global_ref (emacs_env *env, emacs_value ref)
if (i >= 0)
{
Lisp_Object value = HASH_VALUE (h, i);
- eassert (NATNUMP (value));
EMACS_INT refcount = XFASTINT (value) + 1;
if (refcount > MOST_POSITIVE_FIXNUM)
{
@@ -293,7 +291,6 @@ module_free_global_ref (emacs_env *env, emacs_value ref)
/* FIXME: Wait a minute. Shouldn't this function report an error if
the hash lookup fails? */
MODULE_HANDLE_SIGNALS_VOID;
- eassert (HASH_TABLE_P (Vmodule_refs_hash));
struct Lisp_Hash_Table *h = XHASH_TABLE (Vmodule_refs_hash);
Lisp_Object obj = value_to_lisp (ref);
EMACS_UINT hashcode;
@@ -302,7 +299,6 @@ module_free_global_ref (emacs_env *env, emacs_value ref)
if (i >= 0)
{
Lisp_Object value = HASH_VALUE (h, i);
- eassert (NATNUMP (value));
EMACS_INT refcount = XFASTINT (value) - 1;
if (refcount > 0)
{
@@ -310,10 +306,7 @@ module_free_global_ref (emacs_env *env, emacs_value ref)
set_hash_value_slot (h, i, value);
}
else
- {
- eassert (refcount == 0);
- hash_remove_from_table (h, value);
- }
+ hash_remove_from_table (h, value);
}
}
@@ -670,7 +663,6 @@ module_vec_size (emacs_env *env, emacs_value vec)
module_wrong_type (env, Qvectorp, lvec);
return 0;
}
- eassert (ASIZE (lvec) >= 0);
return ASIZE (lvec);
}
@@ -894,7 +886,7 @@ finalize_storage (struct emacs_value_storage *storage)
}
/* Allocate a new value from STORAGE and stores OBJ in it. Return
- NULL if allocations fails and use ENV for non local exit reporting. */
+ NULL if allocation fails and use ENV for non local exit reporting. */
static emacs_value
allocate_emacs_value (emacs_env *env, struct emacs_value_storage *storage,
Lisp_Object obj)