diff options
author | kdx <kikoodx@paranoici.org> | 2023-06-18 17:50:15 +0200 |
---|---|---|
committer | kdx <kikoodx@paranoici.org> | 2023-06-18 17:50:15 +0200 |
commit | 3c0b034ee902432baed7030cc65cb2443a846600 (patch) | |
tree | 19d3d11642d1d1e363d44029a2d6d17218a3ec59 /samples | |
parent | 874245962e04264ab3c8a993a109f1790ddb36e2 (diff) | |
download | golem-3c0b034ee902432baed7030cc65cb2443a846600.tar.gz |
local init accepts any expr
Diffstat (limited to 'samples')
-rw-r--r-- | samples/malloc.golem | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/samples/malloc.golem b/samples/malloc.golem index a52d51e..1a3b1a9 100644 --- a/samples/malloc.golem +++ b/samples/malloc.golem @@ -1,8 +1,7 @@ main() => nopipe() |> pipe(); nopipe() { - local s; - s = strdup("yo comment cava\n"); + local s = strdup("yo comment cava\n"); write(s); stoupper(s); write(s); @@ -11,8 +10,7 @@ nopipe() { pipe() => strdup("coucou le monde\n") |> write() |> stoupper() |> write(); write(s) { - local o; - o = s; + local o = s; loop { if ([s] == 0) return o; @@ -22,8 +20,7 @@ write(s) { } strlen(s) { - local len; - len = 0; + local len = 0; loop { if ([s + len] == 0) return len; @@ -36,8 +33,7 @@ strdup(s) { } strcpy(dst, src) { - local i; - i = 0; + local i = 0; loop { [dst + i] = [src + i]; if ([src + i] == 0) @@ -47,8 +43,7 @@ strcpy(dst, src) { } stoupper(s) { - local o; - o = s; + local o = s; loop { if ([s] == 0) return o; @@ -61,8 +56,7 @@ define HEAP_SIZE = 4096; global heap[HEAP_SIZE] = 0x69; global heap_size = 0; malloc(n) { - local p; - p = heap + heap_size; + local p = heap + heap_size; heap_size = heap_size + n; if (heap_size > 4096) { write("malloc error: heap is full"); |