Function gstd::ext::oom_panic

source ·
pub fn oom_panic() -> !
Expand description

Out of memory panic

Function is completely free in terms of gas usage.

§Examples

#![no_std]
#![feature(alloc_error_handler)]
#![feature(allocator_api)]

extern crate alloc;

use alloc::alloc::{Global, Layout, Allocator};
use gcore::ext;

#[alloc_error_handler]
fn oom(_layout: Layout) -> ! {
    ext::oom_panic()
}

#[no_mangle]
extern "C" fn handle() {
    let layout = Layout::new::<[u8; 64 * 1024]>();
    if Global.allocate(layout).is_err() {
        alloc::alloc::handle_alloc_error(layout);
    }
}