Skip to content

Commit 91f1234

Browse files
committed
some refactor
1 parent 0b0ef2d commit 91f1234

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

core/iwasm/common/wasm_memory.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,10 @@ wasm_runtime_chain_shared_heaps(WASMSharedHeap *head, WASMSharedHeap *body)
267267
return NULL;
268268
}
269269
for (cur = shared_heap_list; cur; cur = cur->next) {
270-
if (cur->chain_next == body) {
271-
LOG_WARNING("To create shared heap chain, the `body` shared heap "
272-
"can't already be in a chain");
270+
if (cur->chain_next == body || cur->chain_next == head) {
271+
LOG_WARNING(
272+
"To create shared heap chain, both the 'head' and 'body' "
273+
"shared heap can't already be the 'body' in another a chain");
273274
os_mutex_unlock(&shared_heap_list_lock);
274275
return NULL;
275276
}
@@ -600,12 +601,10 @@ wasm_runtime_shared_heap_malloc(WASMModuleInstanceCommon *module_inst,
600601
*p_native_addr = native_addr;
601602
}
602603

603-
if (memory->is_memory64)
604-
return shared_heap->start_off_mem64
605-
+ ((uint8 *)native_addr - shared_heap->base_addr);
606-
else
607-
return shared_heap->start_off_mem32
608-
+ ((uint8 *)native_addr - shared_heap->base_addr);
604+
return memory->is_memory64
605+
? shared_heap->start_off_mem64
606+
: shared_heap->start_off_mem32
607+
+ ((uint8 *)native_addr - shared_heap->base_addr);
609608
}
610609

611610
void

0 commit comments

Comments
 (0)