mirror of
https://github.com/denoland/rusty_v8.git
synced 2024-11-21 20:28:58 +00:00
Impl Drop for CTypeInfo (#1452)
This deallocates the C++ allocation, preventing a memory leak
This commit is contained in:
parent
57c2338212
commit
ab742578f6
@ -2115,6 +2115,8 @@ v8::CTypeInfo* v8__CTypeInfo__New(v8::CTypeInfo::Type ty) {
|
||||
return u.release();
|
||||
}
|
||||
|
||||
void v8__CTypeInfo__DELETE(v8::CTypeInfo* self) { delete self; }
|
||||
|
||||
struct CTypeSequenceType {
|
||||
v8::CTypeInfo::Type c_type;
|
||||
v8::CTypeInfo::SequenceType sequence_type;
|
||||
|
@ -13,6 +13,7 @@ extern "C" {
|
||||
len: usize,
|
||||
tys: *const CTypeSequenceInfo,
|
||||
) -> *mut CTypeInfo;
|
||||
fn v8__CTypeInfo__DELETE(this: &mut CTypeInfo);
|
||||
fn v8__CFunctionInfo__New(
|
||||
return_info: *const CTypeInfo,
|
||||
args_len: usize,
|
||||
@ -72,6 +73,12 @@ impl CTypeInfo {
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for CTypeInfo {
|
||||
fn drop(&mut self) {
|
||||
unsafe { v8__CTypeInfo__DELETE(self) };
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||
#[repr(u8)]
|
||||
pub enum SequenceType {
|
||||
|
Loading…
Reference in New Issue
Block a user