![]() |
libghostty
|
libghostty-vt does require memory allocation for various operations, but is resilient to allocation failures and will gracefully handle out-of-memory situations by returning error codes.
The exact memory management semantics are documented in the relevant functions and data structures.
libghostty-vt uses explicit memory allocation via an allocator interface provided by GhosttyAllocator. The interface is based on the Zig allocator interface, since this has been shown to be a flexible and powerful interface in practice and enables a wide variety of allocation strategies.
For the common case, you can pass NULL as the allocator for any function that accepts one, and libghostty will use a default allocator. The default allocator will be libc malloc/free if libc is linked. Otherwise, a custom allocator is used (currently Zig's SMP allocator) that doesn't require any external dependencies.
For simple use cases, you can ignore this interface entirely by passing NULL as the allocator parameter to functions that accept one. This will use the default allocator (typically libc malloc/free, if libc is linked, but we provide our own default allocator if libc isn't linked).
To use a custom allocator:
Data Structures | |
struct | GhosttyAllocatorVtable |
struct | GhosttyAllocator |