diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-08-18 06:38:30 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-08-18 06:38:30 -0700 |
commit | b79bc438aadeda878eaa2a26c72129edffba4be7 (patch) | |
tree | 0b5e993bb988e49375d5d6d75549ae7e330932ac /lib.h | |
parent | 56ff4d38c78dd99873017c075861efefe5428bad (diff) | |
download | txr-b79bc438aadeda878eaa2a26c72129edffba4be7.tar.gz txr-b79bc438aadeda878eaa2a26c72129edffba4be7.tar.bz2 txr-b79bc438aadeda878eaa2a26c72129edffba4be7.zip |
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.
Diffstat (limited to 'lib.h')
-rw-r--r-- | lib.h | 6 |
1 files changed, 2 insertions, 4 deletions
@@ -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); |