diff options
author | Ben Smith <binjimin@gmail.com> | 2017-03-06 11:34:37 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-06 11:34:37 -0800 |
commit | e4dda12b17a5323a56b6782a6787f258ed2d8c81 (patch) | |
tree | c47e34928fc9b48f5b8dd1579e4c0213074b6494 /src/binary-reader-interpreter.cc | |
parent | b6e5735f3bfbb66d76142fc2f404da796289fc76 (diff) | |
download | wabt-e4dda12b17a5323a56b6782a6787f258ed2d8c81.tar.gz wabt-e4dda12b17a5323a56b6782a6787f258ed2d8c81.tar.bz2 wabt-e4dda12b17a5323a56b6782a6787f258ed2d8c81.zip |
Use new/delete instead of malloc/free (#332)
Also switch some void* -> char*, because it removes some unnecessary
casts. C++ does not like void*.
Diffstat (limited to 'src/binary-reader-interpreter.cc')
-rw-r--r-- | src/binary-reader-interpreter.cc | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/binary-reader-interpreter.cc b/src/binary-reader-interpreter.cc index 15e28a20..58411493 100644 --- a/src/binary-reader-interpreter.cc +++ b/src/binary-reader-interpreter.cc @@ -726,7 +726,7 @@ static Result on_memory(uint32_t index, InterpreterMemory* memory = append_interpreter_memory(&ctx->env->memories); memory->page_limits = *page_limits; memory->byte_size = page_limits->initial * WABT_PAGE_SIZE; - memory->data = wabt_alloc_zero(memory->byte_size); + memory->data = new char[memory->byte_size](); ctx->module->memory_index = ctx->env->memories.size - 1; return Result::Ok; } @@ -953,8 +953,7 @@ static Result on_data_segment_data(uint32_t index, InterpreterMemory* memory = &ctx->env->memories.data[ctx->module->memory_index]; uint32_t address = ctx->init_expr_value.value.i32; - uint8_t* dst_data = static_cast<uint8_t*>(memory->data); - memcpy(&dst_data[address], src_data, size); + memcpy(memory->data + address, src_data, size); return Result::Ok; } |