summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Hurst <julian.hurst@digdash.com>2025-03-20 15:23:42 +0100
committerJulian Hurst <julian.hurst@digdash.com>2025-03-20 15:23:42 +0100
commit1c3531d4da2e2f56bf09c38a756a8c5f7c615b80 (patch)
treef85210a658920f90624eb3de92a8741bc76e6bdb
parente660aa111109bddc35d884140d53f9f4b5da6a17 (diff)
downloadhare-tui-1c3531d4da2e2f56bf09c38a756a8c5f7c615b80.tar.gz
il: add static slice allocation example
-rw-r--r--cmd/il.ha15
1 files changed, 15 insertions, 0 deletions
diff --git a/cmd/il.ha b/cmd/il.ha
index fc5bd40..afc1ee5 100644
--- a/cmd/il.ha
+++ b/cmd/il.ha
@@ -10,11 +10,26 @@ use io;
export fn main() void = {
const scanner = bufio::newscanner(os::stdin);
defer bufio::finish(&scanner);
+
let items: []str = [];
for (let line: const str => bufio::scan_line(&scanner)!) {
append(items, strings::dup(line));
};
defer strings::freeall(items);
+
+ // static slice allocation
+ //let buf: [1024]str = [""...];
+ //let items = buf[..0];
+ //for (let line: const str => bufio::scan_line(&scanner)!) {
+ // match (static append(items, strings::dup(line))) {
+ // case void =>
+ // void;
+ // case nomem =>
+ // fmt::fatal("Error: too many items");
+ // };
+ //};
+ //defer for (let s .. items) free(s);
+
const state = tui::init()!;
defer tui::finish(&state);
let li = list::newscrolllist(