Module allocation

Module allocation 

Source
Expand description

Memory allocation utilities for creating aligned and optimized buffers.

This module provides functions for allocating buffers with specific alignment requirements, particularly page-aligned buffers for optimal DMA performance with io_uring operations. Memory allocation utilities for pinned buffers.

This module provides specialized buffer allocation functions optimized for Direct Memory Access (DMA) operations and io_uring. The allocators ensure proper memory alignment and zero-initialization for safe kernel interactions.

§Key Features

  • Page-aligned allocation for optimal DMA performance
  • Zero-initialized memory for security
  • Custom alignment support for specialized use cases
  • Fallback strategies for allocation failures

§Examples

use safer_ring::buffer::allocation::{allocate_aligned_buffer, allocate_with_alignment};

// Allocate a page-aligned buffer for DMA operations
let buffer = allocate_aligned_buffer(8192);
assert_eq!(buffer.len(), 8192);

// Allocate with custom alignment
let aligned_buffer = allocate_with_alignment(1024, 64);
assert_eq!(aligned_buffer.len(), 1024);

Functions§

allocate_aligned_buffer
Allocates a zero-initialized buffer with optimal alignment for DMA operations.
allocate_with_alignment
Allocates a buffer with specific alignment requirements.