Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/browser/css/libdom_test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,31 @@ const std = @import("std");
const css = @import("css.zig");
const Node = @import("libdom.zig").Node;
const parser = @import("../netsurf.zig");
const Allocator = std.mem.Allocator;

const Matcher = struct {
const Nodes = std.ArrayList(Node);
const Nodes = std.ArrayListUnmanaged(Node);

nodes: Nodes,
allocator: Allocator,

fn init(alloc: std.mem.Allocator) Matcher {
return .{ .nodes = Nodes.init(alloc) };
fn init(allocator: Allocator) Matcher {
return .{
.nodes = .empty,
.allocator = allocator,
};
}

fn deinit(m: *Matcher) void {
m.nodes.deinit();
m.nodes.deinit(m.allocator);
}

fn reset(m: *Matcher) void {
m.nodes.clearRetainingCapacity();
}

pub fn match(m: *Matcher, n: Node) !void {
try m.nodes.append(n);
try m.nodes.append(m.allocator, n);
}
};

Expand Down
14 changes: 9 additions & 5 deletions src/browser/css/match_test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -84,24 +84,28 @@ pub const Node = struct {
};

const Matcher = struct {
const Nodes = std.ArrayList(*const Node);
const Nodes = std.ArrayListUnmanaged(*const Node);

nodes: Nodes,
allocator: Allocator,

fn init(alloc: std.mem.Allocator) Matcher {
return .{ .nodes = Nodes.init(alloc) };
fn init(allocator: Allocator) Matcher {
return .{
.nodes = .empty,
.allocator = allocator,
};
}

fn deinit(m: *Matcher) void {
m.nodes.deinit();
m.nodes.deinit(self.allocator);
}

fn reset(m: *Matcher) void {
m.nodes.clearRetainingCapacity();
}

pub fn match(m: *Matcher, n: *const Node) !void {
try m.nodes.append(n);
try m.nodes.append(self.allocator, n);
}
};

Expand Down
Loading