hare

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

commit b84d28615570fa186a4c2d047c8043bf7f91dc13
parent 9ab47de0abbc69e30d8b5039e919b6c0937fdbda
Author: Drew DeVault <sir@cmpwn.com>
Date:   Mon, 22 Feb 2021 19:32:36 -0500

all: update allocations

Diffstat:
Mbufio/fixed.ha | 2+-
Mfmt/fmt.ha | 2+-
Mio/limit.ha | 17++++++++---------
Mos/+linux/environ.ha | 2+-
Mos/+linux/fdstream.ha | 2+-
Mos/exec/+linux.ha | 4++--
Mos/exec/cmd.ha | 2+-
Mstrings/concat.ha | 2+-
Mstrings/tokenize.ha | 2+-
9 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/bufio/fixed.ha b/bufio/fixed.ha @@ -8,7 +8,7 @@ export type fixed_stream = struct { }; export fn fixed(in: []u8) *io::stream = { - let s = alloc(*fixed_stream, fixed_stream { + let s = alloc(fixed_stream { stream = io::stream { name = "<bufio::fixed>", reader = &fixed_read, diff --git a/fmt/fmt.ha b/fmt/fmt.ha @@ -211,7 +211,7 @@ fn format( }; fn scan_uint(iter: *strings::iterator) uint = { - let num = alloc([]u8, []); + let num: []u8 = []; defer free(num); for (true) { let r = match (strings::next(iter)) { diff --git a/io/limit.ha b/io/limit.ha @@ -7,15 +7,14 @@ type limited_stream = struct { }; fn limited_stream_new(source: *stream, limit: size) *limited_stream = { - return alloc(*limited_stream, - limited_stream { - stream = stream { - name = strings::dup(source.name), - closer = &limited_close, - ... - }, - source = source, - limit = limit, + return alloc(limited_stream { + stream = stream { + name = strings::dup(source.name), + closer = &limited_close, + ... + }, + source = source, + limit = limit, }); }; diff --git a/os/+linux/environ.ha b/os/+linux/environ.ha @@ -18,7 +18,7 @@ let args_static: [32]str = [""...]; args[i] = strings::from_c(rt::argv[i]); }; } else { - args = alloc([]str, [], rt::argc); + args = alloc([], rt::argc); for (let i = 0z; i < rt::argc; i += 1) { append(args, strings::from_c(rt::argv[i])); }; diff --git a/os/+linux/fdstream.ha b/os/+linux/fdstream.ha @@ -31,7 +31,7 @@ fn static_fdopen( // Opens a Unix file descriptor as an io::stream. export fn fdopen(fd: int, name: str, mode: io::mode) *io::stream = { - let stream = alloc(*fd_stream, fd_stream { ... }); + let stream = alloc(fd_stream { ... }); static_fdopen(fd, strings::dup(name), mode, stream); stream.stream.closer = &fd_close; return &stream.stream; diff --git a/os/exec/+linux.ha b/os/exec/+linux.ha @@ -47,7 +47,7 @@ fn platform_finish(cmd: *command) void = { }; fn platform_exec(cmd: *command) os_error = { - let argv = alloc([]nullable *const char, [], len(cmd.argv) + 1z); + let argv: []nullable *const char = alloc([], len(cmd.argv) + 1z); for (let i = 0z; i < len(cmd.argv); i += 1z) { append(argv, cmd.argv[i]: *const char); }; @@ -55,7 +55,7 @@ fn platform_exec(cmd: *command) os_error = { let envp: nullable *[*]nullable *const char = null; if (len(cmd.envp) != 0) { - let env = alloc([]nullable *const char, [], len(cmd.envp) + 1); + let env: []nullable *const char = alloc([], len(cmd.envp) + 1); for (let i = 0z; i < len(cmd.envp); i += 1) { append(env, cmd.envp[i]: *const char); }; diff --git a/os/exec/cmd.ha b/os/exec/cmd.ha @@ -45,7 +45,7 @@ export fn cmd(name: str, args: str...) (command | error) = { void => return nocmd, p: platform => p, }, - argv = alloc([]str, [], len(args) + 1z), + argv = alloc([], len(args) + 1z), ... }; append(cmd.argv, name); diff --git a/strings/concat.ha b/strings/concat.ha @@ -4,7 +4,7 @@ export fn concat(strs: str...) str = { for (let i = 0z; i < len(strs); i += 1) { z += len(strs[i]); }; - let new = alloc([]u8, [], z + 1); + let new: []u8 = alloc([], z + 1); for (let i = 0z; i < len(strs); i += 1) { append(new, ...to_utf8(strs[i])); }; diff --git a/strings/tokenize.ha b/strings/tokenize.ha @@ -81,7 +81,7 @@ export fn remaining_tokens(s: *tokenizer) str = { // borrowed from 'in', and needn't be freed - but should be [strings::dup_all]'d // if they should outlive 'in'. export fn splitN(in: str, delim: str, n: size) []str = { - let toks = alloc([]str, []); + let toks: []str = alloc([]); let tok = tokenize(in, delim); for (let i = 0z; i < n - 1z; i += 1) { match (next_token(&tok)) {