added
[rrq/rrqforth.git] / adoc / p_malloc.adoc
1 // stdio.asm:   WORD p_malloc,'MALLOC',fasm
2
3 anchor:p_malloc[]
4
5 === Word: MALLOC
6
7 ....
8 Data stack: ( n -- a )
9 ....
10
11 "MALLOC" is a word that allocates memory using mmap of at least n
12 bytes and returns the lowest address of the allocated block.
13
14 Note that this makes new page allocations for the process from the
15 kernel, and the granularity is in pages, i.e. a multiple of 4 kb.
16
17 The memory is allocated with READ and WRITE access but not EXEC
18 access, and flagged as PRIVATE, ANONYMOUS and LOCKED. See the "man
19 page" of mmap for details.
20
21 See also <<p_stream,STREAM>>