aboutsummaryrefslogtreecommitdiff
path: root/src/alloc.zig
blob: ed790d096f5c6077e55768f0c0981ef5bda25ccc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const std = @import("std");

const STATIC_MEMORY_SIZE = 256000;
pub var static_manager: ?std.heap.ArenaAllocator = null;
pub var root_manager: ?RootAlloc = null;
pub var needs_setup: bool = true;
pub var static: *std.mem.Allocator = undefined;
pub var dynamic: *std.mem.Allocator = undefined;

pub fn setup(root: *std.mem.Allocator) !void {
    needs_setup = false;
    static = root;
    dynamic = root;
    // static = @ptrCast(*std.mem.Allocator, &stat.allocator);
}

test "GlobalAllocator" {
    try setup(std.heap.page_allocator);
    var testType = try static.alloc(u8, 10);
    testType[1] = 1;
}