commit 21bb848e1113174f73d5f616c4372433f89f9076 parent 39d7c53bf72a3dc7c249b433637cc80ee3ac7654 Author: Sebastian <sebastian@sebsite.pw> Date: Sun, 20 Mar 2022 00:26:14 -0400 ast: free docs in decl_free Signed-off-by: Sebastian <sebastian@sebsite.pw> Diffstat:
M | hare/ast/decl.ha | | | 55 | +++++++++++++++++++++++++++++-------------------------- |
1 file changed, 29 insertions(+), 26 deletions(-)
diff --git a/hare/ast/decl.ha b/hare/ast/decl.ha @@ -63,31 +63,34 @@ export type decl = struct { }; // Frees resources associated with a declaration. -export fn decl_free(d: decl) void = match (d.decl) { -case let g: []decl_global => - for (let i = 0z; i < len(g); i += 1) { - free(g[i].symbol); - ident_free(g[i].ident); - type_free(g[i]._type); - expr_free(g[i].init); +export fn decl_free(d: decl) void = { + free(d.docs); + match (d.decl) { + case let g: []decl_global => + for (let i = 0z; i < len(g); i += 1) { + free(g[i].symbol); + ident_free(g[i].ident); + type_free(g[i]._type); + expr_free(g[i].init); + }; + free(g); + case let t: []decl_type => + for (let i = 0z; i < len(t); i += 1) { + ident_free(t[i].ident); + type_free(t[i]._type); + }; + free(t); + case let f: decl_func => + free(f.symbol); + ident_free(f.ident); + type_free(f.prototype); + if (f.body is expr) expr_free(f.body as expr); + case let c: []decl_const => + for (let i = 0z; i < len(c); i += 1) { + ident_free(c[i].ident); + type_free(c[i]._type); + expr_free(c[i].init); + }; + free(c); }; - free(g); -case let t: []decl_type => - for (let i = 0z; i < len(t); i += 1) { - ident_free(t[i].ident); - type_free(t[i]._type); - }; - free(t); -case let f: decl_func => - free(f.symbol); - ident_free(f.ident); - type_free(f.prototype); - if (f.body is expr) expr_free(f.body as expr); -case let c: []decl_const => - for (let i = 0z; i < len(c); i += 1) { - ident_free(c[i].ident); - type_free(c[i]._type); - expr_free(c[i].init); - }; - free(c); };