Skip to content

Commit

Permalink
managed dealloc - api
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-marinica committed Jun 10, 2024
1 parent f27462e commit a25bb62
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 6 additions & 0 deletions framework/base/src/api/managed_types/managed_type_api_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,10 @@ pub trait ManagedTypeApiImpl:
fn get_token_ticker_len(&self, token_id_len: usize) -> usize {
super::token_identifier_util::get_token_ticker_len(token_id_len)
}

fn drop_managed_buffer(&self, _handle: Self::ManagedBufferHandle) {}
fn drop_big_float(&self, _handle: Self::BigFloatHandle) {}
fn drop_big_int(&self, _handle: Self::BigIntHandle) {}
fn drop_elliptic_curve(&self, _handle: Self::EllipticCurveHandle) {}
fn drop_managed_map(&self, _handle: Self::ManagedMapHandle) {}
}
9 changes: 7 additions & 2 deletions framework/base/src/types/managed/basic/managed_buffer.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use crate::{
abi::{TypeAbi, TypeAbiFrom, TypeName},
api::{
use_raw_handle, ErrorApiImpl, HandleConstraints, InvalidSliceError, ManagedBufferApiImpl,
ManagedTypeApi, StaticVarApiImpl,
use_raw_handle, ErrorApiImpl, HandleConstraints, InvalidSliceError, ManagedBufferApiImpl, ManagedTypeApi, ManagedTypeApiImpl, StaticVarApiImpl
},
codec::{
DecodeErrorHandler, Empty, EncodeErrorHandler, NestedDecode, NestedDecodeInput,
Expand Down Expand Up @@ -350,6 +349,12 @@ impl<M: ManagedTypeApi> Clone for ManagedBuffer<M> {
}
}

impl<M: ManagedTypeApi> Drop for ManagedBuffer<M> {
fn drop(&mut self) {
M::managed_type_impl().drop_managed_buffer(self.get_handle());
}
}

impl<M: ManagedTypeApi> PartialEq for ManagedBuffer<M> {
#[inline]
fn eq(&self, other: &Self) -> bool {
Expand Down

0 comments on commit a25bb62

Please sign in to comment.