Skip to content

Commit

Permalink
simplify boxed_reisze
Browse files Browse the repository at this point in the history
  • Loading branch information
StunxFS committed Jan 26, 2024
1 parent c6643bd commit 08e954c
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/core/src/mem/Boxedptr.c.ri
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@ pub func boxed_zeroed(size: uint, dtor: ?BoxedptrDestroy := none) -> boxedptr {
}

pub func boxed_resize(ptr: boxedptr, size: uint) -> boxedptr {
old_boxed := Boxedptr.from_boxedptr(ptr);
new_boxed := unsafe {
@as(&mut Boxedptr, raw_resize(old_boxed, BOXEDPTR_SIZE + size))
};
new_boxed.value = unsafe {
@as(boxedptr, @ptr_add(@as([&]uint8, new_boxed), BOXEDPTR_SIZE))
@as(
&mut Boxedptr, raw_resize(Boxedptr.from_boxedptr(ptr), BOXEDPTR_SIZE + size)
)
};
return new_boxed.value;
}
Expand Down

0 comments on commit 08e954c

Please sign in to comment.