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

JavaScript | PHP


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();
<?php

$m = zigar_use(__DIR__ . '/allocator-js-example-1.zig');

$buf = $m->allocator->alloc(128, 256);
$m->allocator->free($buf);

Arguments:

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

Return value:

ArrayBuffer