42 lines
629 B
Text
42 lines
629 B
Text
include 'std/syscall.fa'
|
|
|
|
|
|
--<
|
|
Allocate memory
|
|
|
|
Takes:
|
|
INT: The buffer size
|
|
|
|
Returns:
|
|
INT: *buffer
|
|
>--
|
|
fun malloc [ int ] int eo
|
|
as __malloc_length -- Element from the stack
|
|
|
|
34 -- Flags
|
|
0 -- Offset
|
|
-1 -- Fd
|
|
3 -- Prot
|
|
@__malloc_length
|
|
deref -- Length
|
|
0 -- Addr
|
|
%SYS_mmap sys 7
|
|
|
|
unname __malloc_length
|
|
end
|
|
|
|
|
|
--<
|
|
Deallocate memory
|
|
|
|
Takes:
|
|
INT: The buffer size
|
|
INT: *buffer
|
|
|
|
Returns:
|
|
INT: ?error
|
|
>--
|
|
fun mfree [ int int ] int eo
|
|
%SYS_munmap sys 3
|
|
end
|
|
|