This commit is contained in:
Karl Seguin
2026-04-09 12:01:56 +08:00
parent 255fa247c3
commit cec9628e37
2 changed files with 10 additions and 9 deletions

View File

@@ -31,12 +31,13 @@ pub fn main() !void {
// allocator
// - in Debug mode we use the General Purpose Allocator to detect memory leaks
// - in Release mode we use the c allocator
var gpa_instance: std.heap.DebugAllocator(.{ .stack_trace_frames = 10 }) = .init;
const gpa = if (builtin.mode == .Debug) gpa_instance.allocator() else std.heap.c_allocator;
// var gpa_instance: std.heap.DebugAllocator(.{ .stack_trace_frames = 10 }) = .init;
// const gpa = if (builtin.mode == .Debug) gpa_instance.allocator() else std.heap.c_allocator;
const gpa = std.heap.c_allocator;
defer if (builtin.mode == .Debug) {
if (gpa_instance.detectLeaks()) std.posix.exit(1);
};
// defer if (builtin.mode == .Debug) {
// if (gpa_instance.detectLeaks()) std.posix.exit(1);
// };
// arena for main-specific allocations
var main_arena_instance = std.heap.ArenaAllocator.init(gpa);

View File

@@ -107,7 +107,7 @@ pub const Event = union(enum) {
const Navigate = struct {
tls: bool,
proxy: bool,
driver: enum{cdp} = .cdp,
driver: enum { cdp } = .cdp,
};
const BufferOverflow = struct {
@@ -165,9 +165,9 @@ test "telemetry: sends event to provider" {
telemetry.disabled = false;
const mock = telemetry.provider;
telemetry.record(.{ .buffer_overflow = .{.dropped = 1} });
telemetry.record(.{ .buffer_overflow = .{.dropped = 2} });
telemetry.record(.{ .buffer_overflow = .{.dropped = 3} });
telemetry.record(.{ .buffer_overflow = .{ .dropped = 1 } });
telemetry.record(.{ .buffer_overflow = .{ .dropped = 2 } });
telemetry.record(.{ .buffer_overflow = .{ .dropped = 3 } });
try testing.expectEqual(3, mock.events.items.len);
for (mock.events.items, 0..) |event, i| {