blob: 5bd40d240d5f3540812abd7137af8da4efb9b4a9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
.TH qlibs: alloc 3
.SH NAME
alloc \- allocate memory
.SH SYNTAX
.B #include \(dqalloc.h\(dq
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 "CVE-2005-1513"
This version of
.B alloc
respects
.I limits.h
to avoid memory resource exhaustion.
.SH "SEE ALSO"
sbrk(2),
malloc(3),
error(3)
|