diff options
Diffstat (limited to 'samples/malloc.golem')
-rw-r--r-- | samples/malloc.golem | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/samples/malloc.golem b/samples/malloc.golem index 1a3b1a9..a920e4e 100644 --- a/samples/malloc.golem +++ b/samples/malloc.golem @@ -1,4 +1,7 @@ -main() => nopipe() |> pipe(); +main() { + nopipe(); + pipe(); +} nopipe() { local s = strdup("yo comment cava\n"); @@ -28,9 +31,7 @@ strlen(s) { } } -strdup(s) { - return strcpy(malloc(strlen(s) + 1), s); -} +strdup(s) => malloc(strlen(s) + 1) |> strcpy(s); strcpy(dst, src) { local i = 0; @@ -59,7 +60,7 @@ malloc(n) { local p = heap + heap_size; heap_size = heap_size + n; if (heap_size > 4096) { - write("malloc error: heap is full"); + write("malloc error: heap is full\n"); return 0; } return p; |