pub fn realloc_bytes(ptr: raw_ptr, count: u64, new_count: u64) -> raw_ptr 
Expand description

Reallocates the given area of memory in individual bytes.

Arguments

  • ptr: [raw_ptr] - The pointer to the area of memory to reallocate.
  • count: [u64] - The number of bytes kept when reallocating. These are not set to 0.
  • new_count: [u64] - The number of new bytes to allocate. These are set to 0.

Returns

  • [raw_ptr] - The pointer to the newly reallocated memory.

Examples

use std::alloc::{alloc_bytes, realloc_bytes};

fn foo() {
    let ptr = alloc_bytes(8);
    ptr.write(5);
    let reallocated_ptr = realloc_bytes(ptr, 8, 16);
    assert(reallocated_ptr.read::<u64>() == 5);
}