| 1 | .TH alloc 3 |
| 2 | .SH NAME |
| 3 | alloc \- allocate memory |
| 4 | .SH SYNTAX |
| 5 | .B #include <alloc.h> |
| 6 | |
| 7 | char *\fBalloc\fP(\fInew\fR); |
| 8 | |
| 9 | void \fBalloc_free\fP(\fIx\fR); |
| 10 | |
| 11 | void \fBalloc_re\fP(&\fIx\fR,\fIold\fR,\fInew\fR); |
| 12 | |
| 13 | char *\fIx\fR; |
| 14 | .br |
| 15 | unsigned int \fIold\fR; |
| 16 | .br |
| 17 | unsigned int \fInew\fR; |
| 18 | .SH DESCRIPTION |
| 19 | .B alloc |
| 20 | allocates enough space from the heap for |
| 21 | .I new |
| 22 | bytes of data, |
| 23 | adequately aligned for any data type. |
| 24 | .I new |
| 25 | may be 0. |
| 26 | .B alloc |
| 27 | returns a pointer to the space. |
| 28 | If space is not available, |
| 29 | .B alloc |
| 30 | returns 0, |
| 31 | setting |
| 32 | .B errno |
| 33 | appropriately. |
| 34 | |
| 35 | .B alloc_free |
| 36 | returns space to the heap. |
| 37 | |
| 38 | .B alloc_re |
| 39 | expands the space allocated to |
| 40 | .I x |
| 41 | from |
| 42 | .I old |
| 43 | bytes to |
| 44 | .I new |
| 45 | bytes. |
| 46 | It allocates new space, |
| 47 | copies |
| 48 | .I old |
| 49 | bytes from the old space to the new space, |
| 50 | returns the old space to the heap, |
| 51 | and changes |
| 52 | .I x |
| 53 | to point to the new space. |
| 54 | It then returns 1. |
| 55 | If space is not available, |
| 56 | .B alloc_re |
| 57 | returns 0, |
| 58 | leaving the old space alone. |
| 59 | .SH "SEE ALSO" |
| 60 | sbrk(2), |
| 61 | malloc(3), |
| 62 | error(3) |