diff options
| author | Max Mouratov <mmouratov@gmail.com> | 2014-05-29 05:11:47 +0600 |
|---|---|---|
| committer | Max Mouratov <mmouratov@gmail.com> | 2017-03-17 20:39:03 +0500 |
| commit | 02a8b999f08dcbf6cfcdc1145f3286392d26ad52 (patch) | |
| tree | a6d5a5f5566238184890c94efff644e9d8d2b4ae /asmrun | |
| parent | 1a8af593ad2c179d2f30dede6f88f71be54f40c0 (diff) | |
| download | ocaml-02a8b999f08dcbf6cfcdc1145f3286392d26ad52.tar.gz | |
runtime: replacing direct calls to malloc/calloc/realloc/free with calls to caml_stat_*
A few more wrappers were added (caml_stat_alloc_noexc, caml_stat_resize_noexc,
caml_stat_calloc_noexc) that do not throw an exception in case of errors and
offer a compatible substitute to the corresponding stdlib functions.
Diffstat (limited to 'asmrun')
| -rw-r--r-- | asmrun/backtrace_prim.c | 4 | ||||
| -rw-r--r-- | asmrun/spacetime.c | 9 |
2 files changed, 7 insertions, 6 deletions
diff --git a/asmrun/backtrace_prim.c b/asmrun/backtrace_prim.c index 4641d4e1bc..7691a7b4b0 100644 --- a/asmrun/backtrace_prim.c +++ b/asmrun/backtrace_prim.c @@ -71,8 +71,8 @@ frame_descr * caml_next_frame_descriptor(uintnat * pc, char ** sp) int caml_alloc_backtrace_buffer(void){ CAMLassert(caml_backtrace_pos == 0); - caml_backtrace_buffer = malloc(BACKTRACE_BUFFER_SIZE - * sizeof(backtrace_slot)); + caml_backtrace_buffer = + caml_stat_alloc_noexc(BACKTRACE_BUFFER_SIZE * sizeof(backtrace_slot)); if (caml_backtrace_buffer == NULL) return -1; return 0; } diff --git a/asmrun/spacetime.c b/asmrun/spacetime.c index 7c00b01217..aaf7f6af8e 100644 --- a/asmrun/spacetime.c +++ b/asmrun/spacetime.c @@ -102,7 +102,7 @@ static void reinitialise_free_node_block(void) { size_t index; - start_of_free_node_block = (char*) malloc(chunk_size); + start_of_free_node_block = (char*) caml_stat_alloc_noexc(chunk_size); end_of_free_node_block = start_of_free_node_block + chunk_size; for (index = 0; index < chunk_size / sizeof(value); index++) { @@ -254,7 +254,7 @@ void caml_spacetime_initialize(void) void caml_spacetime_register_shapes(void* dynlinked_table) { shape_table* table; - table = (shape_table*) malloc(sizeof(shape_table)); + table = (shape_table*) caml_stat_alloc_noexc(sizeof(shape_table)); if (table == NULL) { fprintf(stderr, "Out of memory whilst registering shape table"); abort(); @@ -279,7 +279,7 @@ void caml_spacetime_register_thread( { per_thread* thr; - thr = (per_thread*) malloc(sizeof(per_thread)); + thr = (per_thread*) caml_stat_alloc_noexc(sizeof(per_thread)); if (thr == NULL) { fprintf(stderr, "Out of memory while registering thread for profiling\n"); abort(); @@ -725,7 +725,8 @@ static NOINLINE void* find_trie_node_from_libunwind(int for_allocation, have_frames_already = 1; } else { - frames = (struct ext_table*) malloc(sizeof(struct ext_table)); + frames = + (struct ext_table*) caml_stat_alloc_noexc(sizeof(struct ext_table)); if (!frames) { caml_fatal_error("Not enough memory for ext_table allocation"); } |
