From b79bc438aadeda878eaa2a26c72129edffba4be7 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 18 Aug 2017 06:38:30 -0700 Subject: Revising out-of-memory handling. We don't want to be aborting on OOM, but throwing an exception. * lib.c (alloc_error_s): New symbol variable. (oom_realloc): Global variable removed. (oom): New static function. (chk_malloc, chk_malloc_gc_more, chk_calloc, chk_realloc): Call oom instead of removed oom_realloc handler. (env): Throw alloc-error rather than error by calling oom. (obj_init): Initialize alloc_error_s. (init): Drop function pointer argument; do not initialize removed oom_realloc. * lib.h (alloc_error_s): Declared. (oom_realloc): Declaration removed. (init): Declaration updated. * txr.1: Type tree diagram includes alloc-error. --- lib.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'lib.h') diff --git a/lib.h b/lib.h index cc0a65d4..24d04695 100644 --- a/lib.h +++ b/lib.h @@ -467,7 +467,7 @@ extern val eof_s, eol_s, assert_s, name_s; extern val error_s, type_error_s, internal_error_s, panic_s; extern val numeric_error_s, range_error_s; extern val query_error_s, file_error_s, process_error_s, syntax_error_s; -extern val timeout_error_s, system_error_s; +extern val timeout_error_s, system_error_s, alloc_error_s; extern val warning_s, defr_warning_s, restart_s, continue_s; extern val gensym_counter_s; @@ -483,8 +483,6 @@ extern val list_f, less_f, greater_f; extern val prog_string; -extern mem_t *(*oom_realloc)(mem_t *, size_t); - #if HAVE_ULONGLONG_T typedef ulonglong_t alloc_bytes_t; #else @@ -1092,7 +1090,7 @@ val time_parse_local(val format, val string); val time_parse_utc(val format, val string); #endif -void init(mem_t *(*oom_realloc)(mem_t *, size_t), val *stack_bottom); +void init(val *stack_bottom); int compat_fixup(int compat_ver); void dump(val obj, val stream); void d(val obj); -- cgit v1.2.3