tiny.stabilizer.StackPads
Defined in tiny.stabilizer.
API (8)
Actions
Public operations.
Fields and members
Public fields and members.
Source
Source: lib/stabilizer/src/stack.zig:14
zig
pub const StackPads = struct { allocator: Allocator, config: StackConfig, entries: []u8 = &.{}, index: usize = 0, pub fn init(allocator: Allocator, stack_config: StackConfig, rng: *Marsaglia) !StackPads { var self: StackPads = .{ .allocator = allocator, .config = normalizeStackConfig(stack_config), }; if (self.config.enabled) { self.entries = try allocator.alloc(u8, self.config.entries); self.refill(rng); } return self; } pub fn deinit(self: *StackPads) void { if (self.entries.len > 0) self.allocator.free(self.entries); self.* = undefined; } pub fn refill(self: *StackPads, rng: *Marsaglia) void { for (self.entries) |*entry| entry.* = rng.nextByte(); self.index = 0; } pub fn next(self: *StackPads, rng: *Marsaglia) StackPad { if (!self.config.enabled) return .{ .unit = 0, .bytes = 0 }; if (self.index >= self.entries.len) self.refill(rng); const unit = self.entries[self.index]; self.index += 1; return .{ .unit = unit, .bytes = @as(usize, unit) * self.config.alignment }; }};Source: lib/stabilizer/src/root.zig:54
zig
pub const StackPads = stack_mod.StackPads;Audit
| Definitions | 5 |
|---|---|
| Public names | 5 |
| Members | 4 |
| Version | 26.7.0 |
| Revision | daab053ee433 |