hare

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

commit d5380589ed4773ac93a179fd692f7362a51cad49
parent 966678e0657112b34e239dc6aba4461daf91388c
Author: Sebastian <sebastian@sebsite.pw>
Date:   Sun,  1 May 2022 23:26:29 -0400

fs: rename dirent_free to dirent_finish

While here, also fix dirents_free to also free the slice itself, as it's
documented.

Signed-off-by: Sebastian <sebastian@sebsite.pw>

Diffstat:
Mfs/types.ha | 8+++++---
Mfs/util.ha | 3++-
2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/fs/types.ha b/fs/types.ha @@ -154,15 +154,17 @@ export type dirent = struct { ftype: mode, }; -// Duplicates a [[dirent]] object. Call [[dirent_free]] to get rid of it later. +// Duplicates a [[dirent]] object. Call [[dirent_finish]] to get rid of it +// later. export fn dirent_dup(e: *dirent) dirent = { let new = *e; new.name = strings::dup(e.name); return new; }; -// Frees a [[dirent]] object which was duplicated with [[dirent_dup]]. -export fn dirent_free(e: *dirent) void = free(e.name); +// Frees memory associated with a [[dirent]] object which was duplicated with +// [[dirent_dup]]. +export fn dirent_finish(e: *dirent) void = free(e.name); // Flags to use for opening a file. Not all operating systems support all flags; // at a minimum, RDONLY, WRONLY, RDWR, and CREATE will be supported. diff --git a/fs/util.ha b/fs/util.ha @@ -94,8 +94,9 @@ export fn readdir(fs: *fs, path: str) ([]dirent | error) = { // Frees a slice of [[dirent]]s. export fn dirents_free(d: []dirent) void = { for (let i = 0z; i < len(d); i += 1) { - dirent_free(&d[i]); + dirent_finish(&d[i]); }; + free(d); }; // Removes a directory, and anything in it.