Skip to main content

realloc_checked

Function realloc_checked 

Source
pub fn realloc_checked(
    account: &AccountView<'_>,
    new_len: usize,
    payer: Option<&AccountView<'_>>,
) -> ProgramResult
Expand description

Checked realloc that also ensures the account remains rent-exempt after resizing.

This is the safe version of account.resize() – it verifies that the account has enough lamports to cover rent at the new data length.

§Reaping caveat

The top-up target comes from the hardcoded crate::sysvar::rent_exempt_minimum const, so it cannot see a rent reprice. If the cluster ever raises the rent parameters this UNDER-funds the account, leaving it reapable (data loss). Any resize whose safety must survive a reprice should call realloc_checked_with with a freshly read crate::sysvar::Rent.