SDK: Allow integer math in bump allocator
This commit is contained in:
parent
854e6766ce
commit
12399157f5
|
@ -1,4 +1,3 @@
|
||||||
#![allow(clippy::integer_arithmetic)]
|
|
||||||
//! @brief Solana Rust-based BPF program entry point supported by the latest
|
//! @brief Solana Rust-based BPF program entry point supported by the latest
|
||||||
//! BPFLoader. For more information see './bpf_loader.rs'
|
//! BPFLoader. For more information see './bpf_loader.rs'
|
||||||
|
|
||||||
|
@ -104,6 +103,10 @@ pub struct BumpAllocator {
|
||||||
pub start: usize,
|
pub start: usize,
|
||||||
pub len: usize,
|
pub len: usize,
|
||||||
}
|
}
|
||||||
|
/// Integer arithmetic in this global allocator implementation is safe when
|
||||||
|
/// operating on the prescribed `HEAP_START_ADDRESS` and `HEAP_LENGTH`. Any
|
||||||
|
/// other use may overflow and is thus unsupported and at one's own risk.
|
||||||
|
#[allow(clippy::integer_arithmetic)]
|
||||||
unsafe impl std::alloc::GlobalAlloc for BumpAllocator {
|
unsafe impl std::alloc::GlobalAlloc for BumpAllocator {
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
|
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
|
||||||
|
@ -133,6 +136,11 @@ pub const MAX_PERMITTED_DATA_INCREASE: usize = 1_024 * 10;
|
||||||
|
|
||||||
/// Deserialize the input arguments
|
/// Deserialize the input arguments
|
||||||
///
|
///
|
||||||
|
/// The integer arithmetic in this method is safe when called on a buffer that was
|
||||||
|
/// serialized by runtime. Use with buffers serialized otherwise is unsupported and
|
||||||
|
/// done at one's own risk.
|
||||||
|
#[allow(clippy::integer_arithmetic)]
|
||||||
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
#[allow(clippy::type_complexity)]
|
#[allow(clippy::type_complexity)]
|
||||||
pub unsafe fn deserialize<'a>(input: *mut u8) -> (&'a Pubkey, Vec<AccountInfo<'a>>, &'a [u8]) {
|
pub unsafe fn deserialize<'a>(input: *mut u8) -> (&'a Pubkey, Vec<AccountInfo<'a>>, &'a [u8]) {
|
||||||
|
|
Loading…
Reference in New Issue