mirror of
https://github.com/denoland/rusty_v8.git
synced 2025-01-22 06:09:47 -05:00
Impl Drop for CTypeInfo (#1452)
This deallocates the C++ allocation, preventing a memory leak
This commit is contained in:
parent
57c2338212
commit
ab742578f6
2 changed files with 9 additions and 0 deletions
|
@ -2115,6 +2115,8 @@ v8::CTypeInfo* v8__CTypeInfo__New(v8::CTypeInfo::Type ty) {
|
||||||
return u.release();
|
return u.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void v8__CTypeInfo__DELETE(v8::CTypeInfo* self) { delete self; }
|
||||||
|
|
||||||
struct CTypeSequenceType {
|
struct CTypeSequenceType {
|
||||||
v8::CTypeInfo::Type c_type;
|
v8::CTypeInfo::Type c_type;
|
||||||
v8::CTypeInfo::SequenceType sequence_type;
|
v8::CTypeInfo::SequenceType sequence_type;
|
||||||
|
|
|
@ -13,6 +13,7 @@ extern "C" {
|
||||||
len: usize,
|
len: usize,
|
||||||
tys: *const CTypeSequenceInfo,
|
tys: *const CTypeSequenceInfo,
|
||||||
) -> *mut CTypeInfo;
|
) -> *mut CTypeInfo;
|
||||||
|
fn v8__CTypeInfo__DELETE(this: &mut CTypeInfo);
|
||||||
fn v8__CFunctionInfo__New(
|
fn v8__CFunctionInfo__New(
|
||||||
return_info: *const CTypeInfo,
|
return_info: *const CTypeInfo,
|
||||||
args_len: usize,
|
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)]
|
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
pub enum SequenceType {
|
pub enum SequenceType {
|
||||||
|
|
Loading…
Add table
Reference in a new issue