diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2020-03-16 20:55:18 -0400 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2020-03-16 20:55:18 -0400 |
commit | 63ea50be35afb6d7b9dbcd20fe3c31de6187858e (patch) | |
tree | 6356cb27f1285379aa5c46d7863ba7a25364e3f2 /std | |
parent | 6855c6e752e4e4f2f37702477a3b461a51bbc614 (diff) |
updated tests, fixed bugs
Diffstat (limited to 'std')
-rw-r--r-- | std/mem.toc | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/std/mem.toc b/std/mem.toc index 06890b5..5e8c5fa 100644 --- a/std/mem.toc +++ b/std/mem.toc @@ -1,14 +1,14 @@ -// TODO: check for failed malloc -malloc ::= #foreign("malloc", "libc.so.6") fn(#C size_t) #C &"void"; +// TODO: check for failed calloc +calloc ::= #foreign("calloc", "libc.so.6") fn(#C size_t, #C size_t) #C &"void"; free ::= #foreign("free", "libc.so.6") fn(#C &"void"); new ::= fn(t :: Type) &t { - malloc((sizeof t) as u64) + calloc(1, (sizeof t) as u64) } -news ::= fn(t :: Type, n :: int) []t { +news ::= fn(t :: Type, n : int) []t { s: []t; - s.data = malloc((n * sizeof t) as u64); + s.data = calloc(n as u64, (sizeof t) as u64); s.len = n; s } |