mod(memory): do not create items on the stack instead using the provided allocator
Some checks failed
Zig Project Action / Lint, Spell-check and test zig project (push) Failing after 4m26s
Some checks failed
Zig Project Action / Lint, Spell-check and test zig project (push) Failing after 4m26s
This commit is contained in:
@@ -11,15 +11,19 @@ pub fn Widget(comptime Event: type, comptime Renderer: type) type {
|
||||
@compileError("Provided user event `Event` for `Layout(comptime Event: type)` is not of type `union(enum)`.");
|
||||
}
|
||||
return struct {
|
||||
size: terminal.Size = undefined,
|
||||
size_changed: bool = false,
|
||||
allocator: std.mem.Allocator,
|
||||
size: terminal.Size,
|
||||
size_changed: bool,
|
||||
|
||||
pub fn init() @This() {
|
||||
return .{};
|
||||
pub fn init(allocator: std.mem.Allocator) *@This() {
|
||||
var this = allocator.create(@This()) catch @panic("Space.zig: Failed to create.");
|
||||
this.allocator = allocator;
|
||||
this.size_changed = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
pub fn deinit(this: *@This()) void {
|
||||
this.* = undefined;
|
||||
this.allocator.destroy(this);
|
||||
}
|
||||
|
||||
pub fn handle(this: *@This(), event: Event) ?Event {
|
||||
|
||||
Reference in New Issue
Block a user