authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-10-28 03:26:37 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-10-28 03:26:37 -07:00
log0dacc15ec5f7780721bc6668dc81578706ad0d8c
treec076ed6f94f5dfe39ee6e803d6681964bba60c1e
parentd55b67f873b850892dc08f2f5346f95cc3d3fedd

util/yaml- defer parser destroy so that it runs even if try fails


1 files changed, 1 insertions(+), 2 deletions(-)

src/util/yaml.zig+1-2
...@@ -148,6 +148,7 @@ pub const TokenList = []const Token;...@@ -148,6 +148,7 @@ pub const TokenList = []const Token;
148pub fn parse(alloc: *std.mem.Allocator, input: string) !Document {148pub fn parse(alloc: *std.mem.Allocator, input: string) !Document {
149 var parser: c.yaml_parser_t = undefined;149 var parser: c.yaml_parser_t = undefined;
150 _ = c.yaml_parser_initialize(&parser);150 _ = c.yaml_parser_initialize(&parser);
151 defer c.yaml_parser_delete(&parser);
151152
152 const lines = try u.split(input, "\n");153 const lines = try u.split(input, "\n");
153154
...@@ -170,8 +171,6 @@ pub fn parse(alloc: *std.mem.Allocator, input: string) !Document {...@@ -170,8 +171,6 @@ pub fn parse(alloc: *std.mem.Allocator, input: string) !Document {
170 }171 }
171 }172 }
172173
173 c.yaml_parser_delete(&parser);
174
175 const p = &Parser{174 const p = &Parser{
176 .alloc = alloc,175 .alloc = alloc,
177 .tokens = all_events.items,176 .tokens = all_events.items,