Skip to content

API Reference / @gtkx/runtime / alloc

Function: alloc()

alloc(size, gtype?): ExternalObject<Handle>

Defined in: packages/native/index.d.ts:17

Allocates a zero-filled native memory block of size bytes and returns an opaque handle to it. A gtype naming a registered boxed type selects g_boxed_free as the handle's destructor, so a type whose free function has to run is torn down properly. A gtype that is registered but not boxed, such as one from g_pointer_type_register_static, has no boxed free function to select, so the handle owns the block as a plain struct and releases it with g_free.

Parameters

size

number

gtype?

bigint | null

Returns

ExternalObject<Handle>

Released under the MPL-2.0 License.