Merge pull request #1248 from davidhewitt/freelist-lifetime
Fix lifetime soundness in freelist
This commit is contained in:
commit
ef50a10537
|
@ -267,7 +267,7 @@ fn impl_class(
|
||||||
quote! {
|
quote! {
|
||||||
impl pyo3::freelist::PyClassWithFreeList for #cls {
|
impl pyo3::freelist::PyClassWithFreeList for #cls {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_free_list(_py: pyo3::Python) -> &'static mut pyo3::freelist::FreeList<*mut pyo3::ffi::PyObject> {
|
fn get_free_list(_py: pyo3::Python) -> &mut pyo3::freelist::FreeList<*mut pyo3::ffi::PyObject> {
|
||||||
static mut FREELIST: *mut pyo3::freelist::FreeList<*mut pyo3::ffi::PyObject> = 0 as *mut _;
|
static mut FREELIST: *mut pyo3::freelist::FreeList<*mut pyo3::ffi::PyObject> = 0 as *mut _;
|
||||||
unsafe {
|
unsafe {
|
||||||
if FREELIST.is_null() {
|
if FREELIST.is_null() {
|
||||||
|
|
|
@ -12,7 +12,7 @@ use std::os::raw::c_void;
|
||||||
/// The performance improvement applies to types that are often created and deleted in a row,
|
/// The performance improvement applies to types that are often created and deleted in a row,
|
||||||
/// so that they can benefit from a freelist.
|
/// so that they can benefit from a freelist.
|
||||||
pub trait PyClassWithFreeList {
|
pub trait PyClassWithFreeList {
|
||||||
fn get_free_list(py: Python) -> &'static mut FreeList<*mut ffi::PyObject>;
|
fn get_free_list(py: Python) -> &mut FreeList<*mut ffi::PyObject>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Slot<T> {
|
pub enum Slot<T> {
|
||||||
|
|
Loading…
Reference in a new issue