Skip to content

Commit

Permalink
Use a typed Box deallocator in the inspector.
Browse files Browse the repository at this point in the history
  • Loading branch information
iddm committed Sep 18, 2023
1 parent f2835f4 commit 2b402f0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/v8/inspector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl Inspector {
match on_response_callback {
Some(r) => (
Some(on_response::<OnResponse>),
Some(deallocate_box),
Some(deallocate_box::<OnResponse>),
Box::into_raw(Box::new(r)),
),
None => (None, None, std::ptr::null_mut()),
Expand All @@ -119,7 +119,7 @@ impl Inspector {
match on_wait_frontend_message_on_pause_callback {
Some(w) => (
Some(on_wait_frontend_message_on_pause::<OnWait>),
Some(deallocate_box),
Some(deallocate_box::<OnWait>),
Box::into_raw(Box::new(w)),
),
None => (None, None, std::ptr::null_mut()),
Expand Down Expand Up @@ -182,7 +182,7 @@ impl Inspector {
self.raw.as_ptr(),
Some(on_response::<T>),
on_response_callback as _,
Some(deallocate_box),
Some(deallocate_box::<T>),
);
}
}
Expand All @@ -203,7 +203,7 @@ impl Inspector {
self.raw.as_ptr(),
Some(on_wait_frontend_message_on_pause::<T>),
on_wait_frontend_message_on_pause_callback as _,
Some(deallocate_box),
Some(deallocate_box::<T>),
);
}
}
Expand Down Expand Up @@ -361,8 +361,8 @@ extern "C" fn on_wait_frontend_message_on_pause<T: OnWaitFrontendMessageOnPauseC
}

#[allow(clippy::from_raw_with_void_ptr)]
extern "C" fn deallocate_box(raw_box: *mut ::std::os::raw::c_void) {
unsafe { drop(Box::from_raw(raw_box as *mut _)) };
extern "C" fn deallocate_box<T>(raw_box: *mut ::std::os::raw::c_void) {
unsafe { drop(Box::from_raw(raw_box as *mut T)) };
}

#[cfg(test)]
Expand Down

0 comments on commit 2b402f0

Please sign in to comment.