Skip to main content

set_allocator

Function set_allocator 

Source
pub unsafe fn set_allocator(allocator: Option<Allocator>)
Expand description

Replaces the memory allocation functions used by the core C library.

Pass Some to install an allocator, or None to restore libc defaults.

ยงSafety

All of the following must hold:

  • The four functions must belong to a single allocator family.

  • The functions must not return null for non-zero allocs.

  • Returned pointers must satisfy the alignment that libc malloc provides.

  • Call this before any other tree-sitter API call, and do not call it again while live tree-sitter objects exist.

  • This function is not thread-safe.