Skip to content

Marked reserve function as unsafe#426

Open
kitcatier wants to merge 1 commit intokoute:masterfrom
kitcatier:master
Open

Marked reserve function as unsafe#426
kitcatier wants to merge 1 commit intokoute:masterfrom
kitcatier:master

Conversation

@kitcatier
Copy link

pub fn reserve< 'a, T >( length: usize ) -> RelativeSlice< 'a, T > {
unsafe {
let offset = reserve_impl( length * mem::size_of::< T >(), mem::align_of::< T >() );
debug_assert_eq!( ARENA.memory.offset( offset as isize ) as usize % mem::align_of::< T >(), 0 );
RelativeSlice { offset, length, tail: offset, phantom: PhantomData }
}
}

hello, if a function's entire body is unsafe, the function is itself unsafe and should be marked appropriately. Marking them unsafe also means that callers must make sure they know what they're doing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant