diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2023-03-07 02:18:26 +0200 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2023-03-07 02:18:26 +0200 |
| commit | ae5fee63f160643a397d18e9e0658275606bc4d4 (patch) | |
| tree | f68af302374f9ae3c9dbb28dab5547036252d559 /examples/alloc.ct | |
| download | ek-ae5fee63f160643a397d18e9e0658275606bc4d4.tar.gz ek-ae5fee63f160643a397d18e9e0658275606bc4d4.zip | |
initial commit
Diffstat (limited to 'examples/alloc.ct')
| -rw-r--r-- | examples/alloc.ct | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/examples/alloc.ct b/examples/alloc.ct new file mode 100644 index 0000000..5f11bb7 --- /dev/null +++ b/examples/alloc.ct @@ -0,0 +1,18 @@ +/* from c bindings */ + +pub alloc(s usize) *void +{ + p *u8 = malloc(s); + assert(p, "memory allocation failed\n"); + return p; +} + +pub dealloc(p *void) +{ + free(p); +} + +pub realloc(p *, s usize) *void +{ + realloc(p, s); +} |
