rusty_enet 0.4.0

ENet for Rust (and wasm!) transpiled from C.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use core::alloc::Layout;

#[cfg(not(feature = "std"))]
use alloc::alloc::{alloc, dealloc, handle_alloc_error};
#[cfg(feature = "std")]
use std::alloc::{alloc, dealloc, handle_alloc_error};

pub(crate) unsafe fn enet_malloc(layout: Layout) -> *mut u8 {
    let ptr = unsafe { alloc(layout) };
    if ptr.is_null() {
        handle_alloc_error(layout);
    }
    ptr
}

pub(crate) unsafe fn enet_free(ptr: *mut u8, layout: Layout) {
    dealloc(ptr, layout);
}