diff --git a/rust/ares/src/hamt.rs b/rust/ares/src/hamt.rs index 845d773..dcccb5d 100644 --- a/rust/ares/src/hamt.rs +++ b/rust/ares/src/hamt.rs @@ -719,18 +719,31 @@ impl Persist for Hamt { let stem_ptr: *mut Stem = &mut (*next_entry_ptr).stem; let stem_size = (*stem_ptr).size(); + + if pma_contains((*stem_ptr).buffer, stem_size) { + continue; + } + let stem_buffer_ptr = *buffer as *mut Entry; copy_nonoverlapping((*stem_ptr).buffer, stem_buffer_ptr, stem_size); *buffer = stem_buffer_ptr.add(stem_size) as *mut u8; (*stem_ptr).buffer = stem_buffer_ptr; - traversal[depth + 1] = *stem_ptr; depth += 1; } else { // Leaf case let leaf_ptr: *mut Leaf = &mut (*next_entry_ptr).leaf; + + if (*leaf_ptr).len == 0 { + continue; + } + + if pma_contains((*leaf_ptr).buffer, (*leaf_ptr).len) { + continue; + } + let leaf_buffer_ptr = *buffer as *mut (Noun, T); copy_nonoverlapping((*leaf_ptr).buffer, leaf_buffer_ptr, (*leaf_ptr).len);