hare

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

commit 0c736356bf7f1523b3a8a4081158b1e5755f5fb0
parent 0878c0186f15c022fef5dd38b4c3d41bda1eaafc
Author: Eyal Sawady <ecs@d2evs.net>
Date:   Thu, 25 Feb 2021 17:46:12 -0500

rt::{ensure, unensure}: get length from slice

Diffstat:
Mrt/ensure.ha | 10+++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/rt/ensure.ha b/rt/ensure.ha @@ -4,12 +4,12 @@ export type slice = struct { capacity: size, }; -export fn ensure(s: *slice, membsz: size, length: size) void = { +export fn ensure(s: *slice, membsz: size) void = { let cap = s.capacity; - for (cap < length) { + for (cap < s.length) { assert(cap >= s.capacity, "slice out of memory (overflow)"); if (cap == 0) { - cap = length; + cap = s.length; } else { cap *= 2; }; @@ -20,9 +20,9 @@ export fn ensure(s: *slice, membsz: size, length: size) void = { s.data = data; }; -export fn unensure(s: *slice, membsz: size, length: size) void = { +export fn unensure(s: *slice, membsz: size) void = { let cap = s.capacity; - for (cap > length) { + for (cap > s.length) { cap /= 2; }; cap *= 2;