mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +00:00
move safe code out of unsafe block
This commit is contained in:
parent
25c668d72c
commit
ba311319bf
1 changed files with 2 additions and 4 deletions
|
@ -110,10 +110,9 @@ impl IdentStr {
|
||||||
}
|
}
|
||||||
Ordering::Greater => {
|
Ordering::Greater => {
|
||||||
// This needs a big string
|
// This needs a big string
|
||||||
let elements = unsafe {
|
|
||||||
let align = mem::align_of::<u8>();
|
let align = mem::align_of::<u8>();
|
||||||
|
let elements = unsafe {
|
||||||
let layout = Layout::from_size_align_unchecked(len, align);
|
let layout = Layout::from_size_align_unchecked(len, align);
|
||||||
|
|
||||||
alloc(layout)
|
alloc(layout)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -252,10 +251,9 @@ impl Clone for IdentStr {
|
||||||
impl Drop for IdentStr {
|
impl Drop for IdentStr {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
if !self.is_empty() && !self.is_small_str() {
|
if !self.is_empty() && !self.is_small_str() {
|
||||||
unsafe {
|
|
||||||
let align = mem::align_of::<u8>();
|
let align = mem::align_of::<u8>();
|
||||||
|
unsafe {
|
||||||
let layout = Layout::from_size_align_unchecked(self.length, align);
|
let layout = Layout::from_size_align_unchecked(self.length, align);
|
||||||
|
|
||||||
dealloc(self.elements as *mut _, layout);
|
dealloc(self.elements as *mut _, layout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue