Skip to content

Commit

Permalink
make align_alloced_mem_for_struct public
Browse files Browse the repository at this point in the history
  • Loading branch information
cocoa-xu committed Jun 27, 2024
1 parent f9d7cb5 commit 69053df
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion rustler/src/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ fn get_alloc_size_struct<T>() -> usize {
/// Given a pointer `ptr` to an allocation of `get_alloc_size_struct::<T>()` bytes, return the
/// first aligned pointer within the allocation where a `T` may be stored.
/// Unsafe: `ptr` must point to a large enough allocation and not be null.
unsafe fn align_alloced_mem_for_struct<T>(ptr: *const c_void) -> *const c_void {
pub unsafe fn align_alloced_mem_for_struct<T>(ptr: *const c_void) -> *const c_void {
let offset = mem::align_of::<T>() - ((ptr as usize) % mem::align_of::<T>());
ptr.add(offset)
}
Expand Down

0 comments on commit 69053df

Please sign in to comment.