Use Box::into_raw instead of forget vec
This commit is contained in:
parent
c9d9e80acb
commit
419884c6ba
|
@ -5,7 +5,6 @@
|
||||||
use std;
|
use std;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
use std::mem;
|
|
||||||
use std::os::raw::c_void;
|
use std::os::raw::c_void;
|
||||||
|
|
||||||
use crate::class::methods::PyMethodDefType;
|
use crate::class::methods::PyMethodDefType;
|
||||||
|
@ -404,8 +403,7 @@ where
|
||||||
let (new, init, call, mut methods) = py_class_method_defs::<T>()?;
|
let (new, init, call, mut methods) = py_class_method_defs::<T>()?;
|
||||||
if !methods.is_empty() {
|
if !methods.is_empty() {
|
||||||
methods.push(ffi::PyMethodDef_INIT);
|
methods.push(ffi::PyMethodDef_INIT);
|
||||||
type_object.tp_methods = methods.as_mut_ptr();
|
type_object.tp_methods = Box::into_raw(methods.into_boxed_slice()) as *mut _;
|
||||||
mem::forget(methods);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let (None, Some(_)) = (new, init) {
|
if let (None, Some(_)) = (new, init) {
|
||||||
|
@ -426,8 +424,7 @@ where
|
||||||
let mut props = py_class_properties::<T>();
|
let mut props = py_class_properties::<T>();
|
||||||
if !props.is_empty() {
|
if !props.is_empty() {
|
||||||
props.push(ffi::PyGetSetDef_INIT);
|
props.push(ffi::PyGetSetDef_INIT);
|
||||||
type_object.tp_getset = props.as_mut_ptr();
|
type_object.tp_getset = Box::into_raw(props.into_boxed_slice()) as *mut _;
|
||||||
mem::forget(props);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// set type flags
|
// set type flags
|
||||||
|
|
Loading…
Reference in a new issue