| ... | ... | @@ -40,10 +40,26 @@ pub const Node = struct { |
| 40 | 40 | |
| 41 | 41 | pub fn deinit(self: *Node, allocator: Allocator) void { |
| 42 | 42 | switch (self.tag) { |
| 43 | | .doc => @fieldParentPtr(Node.Doc, "base", self).deinit(allocator), |
| 44 | | .map => @fieldParentPtr(Node.Map, "base", self).deinit(allocator), |
| 45 | | .list => @fieldParentPtr(Node.List, "base", self).deinit(allocator), |
| 46 | | .value => @fieldParentPtr(Node.Value, "base", self).deinit(allocator), |
| 43 | .doc => { |
| 44 | const parent = @fieldParentPtr(Node.Doc, "base", self); |
| 45 | parent.deinit(allocator); |
| 46 | allocator.destroy(parent); |
| 47 | }, |
| 48 | .map => { |
| 49 | const parent = @fieldParentPtr(Node.Map, "base", self); |
| 50 | parent.deinit(allocator); |
| 51 | allocator.destroy(parent); |
| 52 | }, |
| 53 | .list => { |
| 54 | const parent = @fieldParentPtr(Node.List, "base", self); |
| 55 | parent.deinit(allocator); |
| 56 | allocator.destroy(parent); |
| 57 | }, |
| 58 | .value => { |
| 59 | const parent = @fieldParentPtr(Node.Value, "base", self); |
| 60 | parent.deinit(allocator); |
| 61 | allocator.destroy(parent); |
| 62 | }, |
| 47 | 63 | } |
| 48 | 64 | } |
| 49 | 65 | |
| ... | ... | @@ -76,7 +92,6 @@ pub const Node = struct { |
| 76 | 92 | pub fn deinit(self: *Doc, allocator: Allocator) void { |
| 77 | 93 | if (self.value) |node| { |
| 78 | 94 | node.deinit(allocator); |
| 79 | | allocator.destroy(node); |
| 80 | 95 | } |
| 81 | 96 | } |
| 82 | 97 | |
| ... | ... | @@ -122,7 +137,6 @@ pub const Node = struct { |
| 122 | 137 | for (self.values.items) |entry| { |
| 123 | 138 | if (entry.value) |value| { |
| 124 | 139 | value.deinit(allocator); |
| 125 | | allocator.destroy(value); |
| 126 | 140 | } |
| 127 | 141 | } |
| 128 | 142 | self.values.deinit(allocator); |
| ... | ... | @@ -163,7 +177,6 @@ pub const Node = struct { |
| 163 | 177 | pub fn deinit(self: *List, allocator: Allocator) void { |
| 164 | 178 | for (self.values.items) |node| { |
| 165 | 179 | node.deinit(allocator); |
| 166 | | allocator.destroy(node); |
| 167 | 180 | } |
| 168 | 181 | self.values.deinit(allocator); |
| 169 | 182 | } |
| ... | ... | @@ -239,7 +252,6 @@ pub const Tree = struct { |
| 239 | 252 | self.line_cols.deinit(); |
| 240 | 253 | for (self.docs.items) |doc| { |
| 241 | 254 | doc.deinit(self.allocator); |
| 242 | | self.allocator.destroy(doc); |
| 243 | 255 | } |
| 244 | 256 | self.docs.deinit(self.allocator); |
| 245 | 257 | } |
| ... | ... | @@ -386,7 +398,6 @@ const Parser = struct { |
| 386 | 398 | } |
| 387 | 399 | errdefer if (node.value) |val| { |
| 388 | 400 | val.deinit(self.allocator); |
| 389 | | self.allocator.destroy(val); |
| 390 | 401 | }; |
| 391 | 402 | |
| 392 | 403 | // Parse footer |
| ... | ... | @@ -426,7 +437,6 @@ const Parser = struct { |
| 426 | 437 | for (node.values.items) |entry| { |
| 427 | 438 | if (entry.value) |val| { |
| 428 | 439 | val.deinit(self.allocator); |
| 429 | | self.allocator.destroy(val); |
| 430 | 440 | } |
| 431 | 441 | } |
| 432 | 442 | node.values.deinit(self.allocator); |
| ... | ... | @@ -467,7 +477,6 @@ const Parser = struct { |
| 467 | 477 | const val = try self.value(); |
| 468 | 478 | errdefer if (val) |v| { |
| 469 | 479 | v.deinit(self.allocator); |
| 470 | | self.allocator.destroy(v); |
| 471 | 480 | }; |
| 472 | 481 | |
| 473 | 482 | if (val) |v| { |
| ... | ... | @@ -503,7 +512,6 @@ const Parser = struct { |
| 503 | 512 | errdefer { |
| 504 | 513 | for (node.values.items) |val| { |
| 505 | 514 | val.deinit(self.allocator); |
| 506 | | self.allocator.destroy(val); |
| 507 | 515 | } |
| 508 | 516 | node.values.deinit(self.allocator); |
| 509 | 517 | } |
| ... | ... | @@ -535,7 +543,6 @@ const Parser = struct { |
| 535 | 543 | errdefer { |
| 536 | 544 | for (node.values.items) |val| { |
| 537 | 545 | val.deinit(self.allocator); |
| 538 | | self.allocator.destroy(val); |
| 539 | 546 | } |
| 540 | 547 | node.values.deinit(self.allocator); |
| 541 | 548 | } |