mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 23:23:28 +00:00
setCAllocator
Replace custom malloc functions in netsurf libs with a global Zig allocator. Signed-off-by: Francis Bouvier <francis@lightpanda.io>
This commit is contained in:
committed by
Pierre Tachoire
parent
f0773a3ca2
commit
76c88d049f
@@ -5,6 +5,7 @@ const jsruntime = @import("jsruntime");
|
||||
const generate = @import("generate.zig");
|
||||
const pretty = @import("pretty");
|
||||
|
||||
const setCAllocator = @import("calloc.zig").setCAllocator;
|
||||
const parser = @import("netsurf.zig");
|
||||
const apiweb = @import("apiweb.zig");
|
||||
const Window = @import("html/window.zig").Window;
|
||||
@@ -87,6 +88,7 @@ fn testsAllExecFn(
|
||||
|
||||
inline for (testFns) |testFn| {
|
||||
try testExecFn(alloc, js_env, testFn);
|
||||
_ = c_arena.reset(.retain_capacity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,6 +117,8 @@ const Run = enum {
|
||||
unit,
|
||||
};
|
||||
|
||||
var c_arena: std.heap.ArenaAllocator = undefined;
|
||||
|
||||
pub fn main() !void {
|
||||
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
||||
defer _ = gpa.deinit();
|
||||
@@ -148,6 +152,10 @@ pub fn main() !void {
|
||||
}
|
||||
}
|
||||
|
||||
c_arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
|
||||
defer c_arena.deinit();
|
||||
setCAllocator(c_arena.allocator());
|
||||
|
||||
// run js tests
|
||||
if (run == .all or run == .browser) try run_js(out);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user