0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2024-11-25 15:29:43 -05:00

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 {