list decrement must use capacity, not length

This commit is contained in:
Folkert 2023-01-14 00:15:50 +01:00
parent 3fda3965ec
commit 437498b7ac
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
3 changed files with 19 additions and 6 deletions

View file

@ -20,7 +20,7 @@ pub const RocList = extern struct {
length: usize,
capacity: usize,
pub fn len(self: RocList) usize {
pub inline fn len(self: RocList) usize {
return self.length;
}
@ -410,9 +410,7 @@ pub fn listWithCapacity(
alignment: u32,
element_width: usize,
) callconv(.C) RocList {
var output = RocList.allocate(alignment, capacity, element_width);
output.length = 0;
return output;
return listReserve(RocList.empty(), alignment, capacity, element_width, .InPlace);
}
pub fn listReserve(