Plan 9 from Bell Labs’s /usr/web/sources/contrib/anothy/src/lib/djb-ape/alloc/alloc.3

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


.TH alloc 3
.SH NAME
alloc \- allocate memory
.SH SYNTAX
.B #include <alloc.h>

char *\fBalloc\fP(\fInew\fR);

void \fBalloc_free\fP(\fIx\fR);

void \fBalloc_re\fP(&\fIx\fR,\fIold\fR,\fInew\fR);

char *\fIx\fR;
.br
unsigned int \fIold\fR;
.br
unsigned int \fInew\fR;
.SH DESCRIPTION
.B alloc
allocates enough space from the heap for
.I new
bytes of data,
adequately aligned for any data type.
.I new
may be 0.
.B alloc
returns a pointer to the space.
If space is not available,
.B alloc
returns 0,
setting
.B errno
appropriately.

.B alloc_free
returns space to the heap.

.B alloc_re
expands the space allocated to
.I x
from
.I old
bytes to
.I new
bytes.
It allocates new space,
copies
.I old
bytes from the old space to the new space,
returns the old space to the heap,
and changes
.I x
to point to the new space.
It then returns 1.
If space is not available,
.B alloc_re
returns 0,
leaving the old space alone.
.SH "SEE ALSO"
sbrk(2),
malloc(3),
error(3)

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.