hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 6f3f633f13e5d3bb26a34f2ae89a0f59452ac515
parent 812126a3108979cb465b2b0c25f11284728a0aaa
Author: Drew DeVault <sir@cmpwn.com>
Date:   Wed, 10 Mar 2021 11:47:00 -0500

hare::module: add context_free

Diffstat:
Mhare/module/context.ha | 12+++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/hare/module/context.ha b/hare/module/context.ha @@ -21,7 +21,8 @@ export type context = struct { tags: []tag, }; -// Initializes a new context with the system default configuration. +// Initializes a new context with the system default configuration. The tag list +// is borrowed from the caller. export fn context_init(tags: []tag) context = { let ctx = context { fs = os::cwd, @@ -55,6 +56,15 @@ export fn context_init(tags: []tag) context = { return ctx; }; +// Frees resources associated with this context. +export fn context_finish(ctx: *context) void = { + for (let i = 0z; i < len(ctx.paths); i += 1) { + free(ctx.paths[i]); + }; + free(ctx.paths); + free(ctx.cache); +}; + // Converts an identifier to a partial path (e.g. foo::bar becomes foo/bar). The // return value must be freed by the caller. export fn ident_path(name: ast::ident) str = {