summaryrefslogtreecommitdiff
path: root/std
diff options
context:
space:
mode:
Diffstat (limited to 'std')
-rw-r--r--std/mem.toc10
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
}