From d8840d4d14a15202601a143edb7b12b8fc267068 Mon Sep 17 00:00:00 2001 From: richerfu Date: Sat, 11 Oct 2025 11:16:10 +0800 Subject: [PATCH] Export globalAllocator and allow to register custom allocator --- src/napi.zig | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/napi.zig b/src/napi.zig index 3be015e..d450815 100644 --- a/src/napi.zig +++ b/src/napi.zig @@ -8,6 +8,8 @@ const err = @import("./napi/wrapper/error.zig"); const thread_safe_function = @import("./napi/wrapper/thread_safe_function.zig"); const class = @import("./napi/wrapper/class.zig"); +const DefaultGlobalAllocator = @import("./napi/util/allocator.zig"); + pub const napi_sys = @import("napi-sys"); pub const Env = env.Env; @@ -34,5 +36,9 @@ pub const ThreadSafeFunction = thread_safe_function.ThreadSafeFunction; pub const Class = class.Class; pub const ClassWithoutInit = class.ClassWithoutInit; +/// Default global allocator is the page allocator +/// You can change it by calling `GlobalAllocator.setGlobalAllocator` +pub const GlobalAllocator = DefaultGlobalAllocator; + pub const NODE_API_MODULE = module.NODE_API_MODULE; pub const NODE_API_MODULE_WITH_INIT = module.NODE_API_MODULE_WITH_INIT;