diff options
author | Kyle Gunger <kgunger12@gmail.com> | 2024-03-26 14:39:54 -0400 |
---|---|---|
committer | Kyle Gunger <kgunger12@gmail.com> | 2024-03-26 14:39:54 -0400 |
commit | 948cfe891a1234f52057db56f7cb1ea088de5ade (patch) | |
tree | e83a406326b083b8215cddb84cbc667f6f4fc4e0 /tnslc/vector.tnsl | |
parent | bb59c119af8ca19fa0eece110f6f7444e52dd558 (diff) |
vector bugfix
Diffstat (limited to 'tnslc/vector.tnsl')
-rw-r--r-- | tnslc/vector.tnsl | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/tnslc/vector.tnsl b/tnslc/vector.tnsl index c8450ac..ea61d78 100644 --- a/tnslc/vector.tnsl +++ b/tnslc/vector.tnsl @@ -35,7 +35,7 @@ uint VECTOR_MAX_GROW = 256 ;/ /; push (~void el) - /; if (self.size == self.count) + /; if (self.size == self.count + 1) /; if (self.size < VECTOR_MAX_GROW) self._grow(self.size) ;; else @@ -45,8 +45,8 @@ uint VECTOR_MAX_GROW = 256 ~void start = self.data + self.count * self._elsz /; loop (int i = 0; i < self._elsz) [i++] - ~void to = start + i - ~void from = el + i + ~uint8 to = start + i + ~uint8 from = el + i to` = from` ;/ self.count++ @@ -63,6 +63,12 @@ uint VECTOR_MAX_GROW = 256 self.push(ch) ;/ + /; as_cstr [~uint8] + ~uint8 z = self.data + self.count + z` = 0 + return self.data + ;/ + /; end self.count = 0 self.size = 0 @@ -71,3 +77,22 @@ uint VECTOR_MAX_GROW = 256 ;/ ;/ + +# Artifacts + +struct Artifact { + ~~uint8 strings, + uint + size, + count +} + +/; method Artifact + + /; init + self.size = VECTOR_MIN_ELEMENTS + self.count = 0 + self.strings = _alloc(self.size * 8) + ;/ +;/ + |