diff options
| author | Julian Hurst <julian.hurst@digdash.com> | 2025-03-20 15:23:42 +0100 |
|---|---|---|
| committer | Julian Hurst <julian.hurst@digdash.com> | 2025-03-20 15:23:42 +0100 |
| commit | 1c3531d4da2e2f56bf09c38a756a8c5f7c615b80 (patch) | |
| tree | f85210a658920f90624eb3de92a8741bc76e6bdb /cmd | |
| parent | e660aa111109bddc35d884140d53f9f4b5da6a17 (diff) | |
| download | hare-tui-1c3531d4da2e2f56bf09c38a756a8c5f7c615b80.tar.gz | |
il: add static slice allocation example
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/il.ha | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -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( |
