0PricingLogin
Zig Academy · Lesson

The Allocator Interface

One contract for all memory sources.

One Common Type

Every allocator in Zig is handed around as a single type, std.mem.Allocator. Your code talks to that one interface, never a concrete backend.

const Allocator = std.mem.Allocator;

An Interface, Not a Class

std.mem.Allocator is a small interface: a pointer plus a table of functions. It describes what an allocator can do, not which one you use.

All lessons in this course

  1. Why Zig Has No Hidden Allocations
  2. The Allocator Interface
  3. alloc, free, create, destroy
  4. Dynamic Lists with ArrayList
← Back to Zig Academy