Improved emscripten code based on comments

This commit is contained in:
Syrus
2019-07-07 17:10:13 -07:00
parent 9c96f01494
commit cb7a1f4486
2 changed files with 1 additions and 29 deletions

View File

@ -32,12 +32,7 @@ pub fn call_malloc(ctx: &mut Ctx, size: u32) -> u32 {
pub fn call_malloc_with_cast<T: Copy, Ty>(ctx: &mut Ctx, size: u32) -> WasmPtr<T, Ty> {
WasmPtr::new(
get_emscripten_data(ctx)
.malloc
.as_ref()
.unwrap()
.call(size)
.unwrap(),
call_malloc(ctx, size),
)
}

View File

@ -66,29 +66,6 @@ pub fn _emscripten_resize_heap(ctx: &mut Ctx, requested_size: u32) -> u32 {
}
}
// function _sbrk(increment) {
// increment = increment | 0;
// var oldDynamicTop = 0;
// var newDynamicTop = 0;
// var totalMemory = 0;
// totalMemory = _emscripten_get_heap_size() | 0;
// oldDynamicTop = HEAP32[DYNAMICTOP_PTR >> 2] | 0;
// newDynamicTop = oldDynamicTop + increment | 0;
// if ((increment | 0) > 0 & (newDynamicTop | 0) < (oldDynamicTop | 0) | (newDynamicTop | 0) < 0) {
// abortOnCannotGrowMemory(newDynamicTop | 0) | 0;
// ___setErrNo(12);
// return -1;
// }
// if ((newDynamicTop | 0) > (totalMemory | 0)) {
// if (_emscripten_resize_heap(newDynamicTop | 0) | 0) {} else {
// ___setErrNo(12);
// return -1;
// }
// }
// HEAP32[DYNAMICTOP_PTR >> 2] = newDynamicTop | 0;
// return oldDynamicTop | 0;
// }
/// emscripten: sbrk
pub fn sbrk(ctx: &mut Ctx, increment: i32) -> i32 {
debug!("emscripten::sbrk");