Merge pull request #315 from kngwyu/remove-forget

Use Box::into_raw instead of forget vec
This commit is contained in:
konstin 2018-12-28 20:27:41 +01:00 committed by GitHub
commit 58a91a3be4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,7 +5,6 @@
use std;
use std::collections::HashMap;
use std::ffi::CString;
use std::mem;
use std::os::raw::c_void;
use crate::class::methods::PyMethodDefType;
@ -404,8 +403,7 @@ where
let (new, init, call, mut methods) = py_class_method_defs::<T>()?;
if !methods.is_empty() {
methods.push(ffi::PyMethodDef_INIT);
type_object.tp_methods = methods.as_mut_ptr();
mem::forget(methods);
type_object.tp_methods = Box::into_raw(methods.into_boxed_slice()) as *mut _;
}
if let (None, Some(_)) = (new, init) {
@ -426,8 +424,7 @@ where
let mut props = py_class_properties::<T>();
if !props.is_empty() {
props.push(ffi::PyGetSetDef_INIT);
type_object.tp_getset = props.as_mut_ptr();
mem::forget(props);
type_object.tp_getset = Box::into_raw(props.into_boxed_slice()) as *mut _;
}
// set type flags