mirror of https://git.sr.ht/~kikoodx/kble
Use a more appropriate allocator for level buffer.
Switched from General Purpous to Arena allocator.
This commit is contained in:
parent
d07a3cd145
commit
cf65e74492
|
@ -68,14 +68,11 @@ pub fn draw(self: *Self, offset: Vec2) void {
|
|||
|
||||
test "create level buffer" {
|
||||
// Create allocator.
|
||||
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
||||
defer {
|
||||
const leaked = gpa.deinit();
|
||||
if (leaked) expect(false); //fail test
|
||||
}
|
||||
const allocator = &gpa.allocator;
|
||||
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
|
||||
defer arena.deinit();
|
||||
const allocator = &arena.allocator;
|
||||
|
||||
// Initialize level struct (twice 'cause why not?).
|
||||
// Initialize level struct and allocate space (twice 'cause why not?).
|
||||
var level: Self = try Self.init(allocator, 64, 32);
|
||||
level.deinit(allocator);
|
||||
level = try Self.init(allocator, 64, 64);
|
||||
|
|
|
@ -11,12 +11,9 @@ const Vec2 = @import("vec2.zig");
|
|||
|
||||
pub fn main() !void {
|
||||
// Create allocator
|
||||
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
||||
defer {
|
||||
const leaked: bool = gpa.deinit();
|
||||
if (leaked) assert(false); //raise error
|
||||
}
|
||||
const allocator = &gpa.allocator;
|
||||
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
|
||||
defer arena.deinit();
|
||||
const allocator = &arena.allocator;
|
||||
|
||||
// Create window.
|
||||
ray.SetConfigFlags(ray.FLAG_WINDOW_RESIZABLE);
|
||||
|
|
Loading…
Reference in New Issue