Function init [src]

Allocate a new RingBuffer; deinit() should be called to free the buffer.

Prototype

pub fn init(allocator: Allocator, capacity: usize) Allocator.Error!RingBuffer

Parameters

allocator: Allocatorcapacity: usize

Source

pub fn init(allocator: Allocator, capacity: usize) Allocator.Error!RingBuffer { const bytes = try allocator.alloc(u8, capacity); return RingBuffer{ .data = bytes, .write_index = 0, .read_index = 0, }; }