Fix memory leak in owner (#2245)
* Fix: memory leak on listeners for elements --------- Co-authored-by: Evan Almloff <evanalmloff@gmail.com>
This commit is contained in:
1 parent
44fe2defc2
commit
633e2a70a4
3 files changed
+16
-6
No files matched your search
@@ -66,6 +66,18 @@ impl<T, S: AnyStorage> Debug for GenerationalBox<T, S> {
|
||||
}
|
||||
|
||||
impl<T, S: Storage<T>> GenerationalBox<T, S> {
|
||||
/// Create a new generational box by leaking a value into the storage. This is useful for creating
|
||||
/// a box that needs to be manually dropped with no owners.
|
||||
#[track_caller]
|
||||
pub fn leak(value: T) -> Self {
|
||||
let mut location = S::claim();
|
||||
location.replace_with_caller(
|
||||
value,
|
||||
#[cfg(any(debug_assertions, feature = "debug_ownership"))]
|
||||
std::panic::Location::caller(),
|
||||
)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub(crate) fn validate(&self) -> bool {
|
||||
#[cfg(any(debug_assertions, feature = "check_generation"))]
|
||||
|
||||
Reference in new issue
Block a user