The returned array is affine and is released with free at scope exit. Its logical element count moves with the allocation and its pointer is available only through checked span views.
localheap=nupp.mem.heapdolocalvalues=heap.allocate(ffi.typeof<int32>(),4)localwritable=values:write()writable[1]=42asint32nupp.drop(writable)localreadable=values:read()print(readable[1],#readable)end-- free runs here
An allocation here sits outside LuaJIT's GC allocation limit, which is the reason to reach for one over a carray. Reading and writing are the operations nupp.mem.span defines, and a live reader and a live writer over one array report NUPP2607.
See c-interop.md for how this sits beside carray, and ownership.md for the borrow rules the views are written against.
Allocates count contiguous values of element outside LuaJIT's GC allocation limit.
The result owns the allocation and frees it at its lexical boundary. The bytes are not zeroed, so a program that reads before it writes reads whatever was there.