Skip to content

Instantly share code, notes, and snippets.

@coderlyfe
coderlyfe / allocators.zig
Created August 30, 2021 04:14
zig memory allocators
const std = @import("std");
pub fn main() !void {
// fixe buffer allocator
var buffer: [1000]u8 = undefined;
const allocator = &std.heap.FixedBufferAllocator.init(&buffer).allocator;
const memory = try allocator.alloc(u8, 5);
defer allocator.free(memory);