Allocator.alloc(len[, align = 1]) - chung-leong/zigar GitHub Wiki

Allocate the specified amount of memory at the specified alignment.

Usage

const std = @import("std");

var gpa = std.heap.DebugAllocator(.{}).init;
pub const allocator = gpa.allocator();
import { allocator } from './allocator-js-example-1.zig';

const dv = allocator.alloc(4);
allocator.free(dv);

Arguments:

  • len
    The number of bytes to allocate.
  • align
    The byte alignment.

Return value:

DataView