hare

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

commit 5ab729d0527edf065676954ed79ea9b213bfd954
parent e8c38d4d4e740e788bbbdd08e2334b0643b5a6e3
Author: Sebastian <sebastian@sebsite.pw>
Date:   Sun, 20 Mar 2022 00:31:11 -0400

io: fix parameters for writeitem and writeitems

This commit fixes the name of an out parameter was incorrectly named
`in`, and the `item` and `items` parameters have had their types changed
from `*void` and `[]void` respectively to `*const void` and
`[]const void`.

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

Diffstat:
Mio/util.ha | 17+++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/io/util.ha b/io/util.ha @@ -52,8 +52,13 @@ export fn readall(in: handle, buf: []u8) (size | EOF | error) = { // Writes an entire "item", i.e. one Hare object, to an I/O handle. This // function may use multiple writes. The return value is the total number of // bytes written (which shall be equal to itemsz). -export fn writeitem(out: handle, item: *void, itemsz: size) (size | error) = { - let buf = item: *[*]u8, i = 0z; +export fn writeitem( + out: handle, + item: *const void, + itemsz: size, +) (size | error) = { + const buf = item: *[*]u8; + let i = 0z; for (i < itemsz) { i += write(out, buf[i..(itemsz - i)])?; }; @@ -62,8 +67,12 @@ export fn writeitem(out: handle, item: *void, itemsz: size) (size | error) = { // Writes several "items", i.e. Hare objects, to an I/O handle. If successful, // all items will be written. The return value is the number of items written. -export fn writeitems(in: handle, items: []void, itemsz: size) (size | error) = { - let buf = items: *[*]u8; +export fn writeitems( + out: handle, + items: []const void, + itemsz: size, +) (size | error) = { + const buf = items: *[*]u8; writeitem(out, buf, len(items) * itemsz)?; return len(items); };