pub fn alloc_pkt(pool: &Arc<MemPool>, size: usize) -> Option<Packet>Expand description
Allocates a packet from the memory pool.
Attempts to allocate a packet buffer of the specified size from the pool. The allocation will fail if:
- The pool is exhausted (no free buffers)
- The requested size exceeds the available space after reserving headroom
§Arguments
pool- The memory pool to allocate fromsize- Desired packet data size in bytes
§Returns
Some(Packet) if allocation succeeded, None otherwise.
§Example
ⓘ
use ixgbe_driver::memory::alloc_pkt;
if let Some(packet) = alloc_pkt(&pool, 1500) {
// Use the packet
} else {
// Handle allocation failure
}