File tree Expand file tree Collapse file tree 8 files changed +144
-122
lines changed Expand file tree Collapse file tree 8 files changed +144
-122
lines changed Original file line number Diff line number Diff line change @@ -20,26 +20,31 @@ const std = @import("std");
2020const css = @import ("css.zig" );
2121const Node = @import ("libdom.zig" ).Node ;
2222const parser = @import ("../netsurf.zig" );
23+ const Allocator = std .mem .Allocator ;
2324
2425const Matcher = struct {
25- const Nodes = std .ArrayList (Node );
26+ const Nodes = std .ArrayListUnmanaged (Node );
2627
2728 nodes : Nodes ,
29+ allocator : Allocator ,
2830
29- fn init (alloc : std.mem.Allocator ) Matcher {
30- return .{ .nodes = Nodes .init (alloc ) };
31+ fn init (allocator : Allocator ) Matcher {
32+ return .{
33+ .nodes = .empty ,
34+ .allocator = allocator ,
35+ };
3136 }
3237
3338 fn deinit (m : * Matcher ) void {
34- m .nodes .deinit ();
39+ m .nodes .deinit (m . allocator );
3540 }
3641
3742 fn reset (m : * Matcher ) void {
3843 m .nodes .clearRetainingCapacity ();
3944 }
4045
4146 pub fn match (m : * Matcher , n : Node ) ! void {
42- try m .nodes .append (n );
47+ try m .nodes .append (m . allocator , n );
4348 }
4449};
4550
Original file line number Diff line number Diff line change @@ -84,24 +84,28 @@ pub const Node = struct {
8484};
8585
8686const Matcher = struct {
87- const Nodes = std .ArrayList (* const Node );
87+ const Nodes = std .ArrayListUnmanaged (* const Node );
8888
8989 nodes : Nodes ,
90+ allocator : Allocator ,
9091
91- fn init (alloc : std.mem.Allocator ) Matcher {
92- return .{ .nodes = Nodes .init (alloc ) };
92+ fn init (allocator : Allocator ) Matcher {
93+ return .{
94+ .nodes = .empty ,
95+ .allocator = allocator ,
96+ };
9397 }
9498
9599 fn deinit (m : * Matcher ) void {
96- m .nodes .deinit ();
100+ m .nodes .deinit (self . allocator );
97101 }
98102
99103 fn reset (m : * Matcher ) void {
100104 m .nodes .clearRetainingCapacity ();
101105 }
102106
103107 pub fn match (m : * Matcher , n : * const Node ) ! void {
104- try m .nodes .append (n );
108+ try m .nodes .append (self . allocator , n );
105109 }
106110};
107111
You can’t perform that action at this time.
0 commit comments