Impl Drop for CTypeInfo (#1452)

This deallocates the C++ allocation, preventing a memory leak
This commit is contained in:
Aaron 2024-04-13 10:07:15 -04:00 committed by GitHub
parent 57c2338212
commit ab742578f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 0 deletions

View File

@ -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;

View File

@ -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 {