summaryrefslogtreecommitdiff
path: root/apps/plugins/pdbox/dbestfit-3.3/malloc.man
blob: 8b6e3dbea5a6db712992fa03c5e200f9d1f0222b (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
MALLOC(3V)             C LIBRARY FUNCTIONS             MALLOC(3V)


NAME
     malloc, free, realloc, calloc

SYNOPSIS
     #include <malloc.h>

     void *malloc(size)
     size_t size;

     void free(ptr)
     void *ptr;

     void *realloc(ptr, size)
     void *ptr;
     size_t size;

     void *calloc(nelem, elsize)
     size_t nelem;
     size_t elsize;

DESCRIPTION
     These routines provide a general-purpose  memory  allocation
     package.  They maintain a table of free blocks for efficient
     allocation and coalescing of free storage.  When there is no
     suitable  space  already  free, the allocation routines call
     rn_getseg() to get more memory from the system.

     Each of the allocation routines returns a pointer  to  space
     suitably  aligned  for  storage  of any type of object. Each
     returns a NULL pointer if the request  cannot  be  completed
     (see DIAGNOSTICS).

     malloc() returns a pointer to  a  block  of  at  least  size
     bytes, which is appropriately aligned.

     free() releases a previously allocated block.  Its  argument
     is  a  pointer  to a block previously allocated by malloc(),
     calloc() or realloc().

     realloc() changes the size of the block referenced by ptr to
     size  bytes  and  returns  a pointer to the (possibly moved)
     block.  The contents will be unchanged up to the  lesser  of
     the  new  and  old sizes.  If unable to honor a reallocation
     request, realloc() leaves its first argument unaltered.

     **** DMALLOC DOES NOT COMPLY WITH THE PARAGRAPH BELOW ****

     For backwards  compatibility,  realloc()  accepts a pointer to a
     block freed since the most recent  call  to  malloc(),  cal-
     loc() or  realloc().

     Note: using realloc() with a block freed before the most recent
     call to malloc(), calloc() or realloc() is an error.

     calloc() uses malloc() to allocate space  for  an  array  of
     nelem  elements  of  size  elsize,  initializes the space to
     zeros, and returns a pointer to the initialized block.   The
     block should be freed with free().


     malloc() and realloc() return a non- NULL pointer if size is 0,
     and calloc() returns a non-NULL pointer if nelem or elsize is 0,
     but these pointers should not be dereferenced.

     Note: Always cast the value returned by malloc(), realloc() or
     calloc().


RETURN VALUES On success, malloc(), calloc() and realloc() return a
     pointer to space suitably aligned for storage of any type of
     object.  On failure, they return NULL.

     free() does not return a value.


NOTES
     Because malloc() and realloc() return a non-NULL pointer if size
     is 0, and calloc() returns a non-NULL pointer if nelem or elsize
     is 0, a zero size need not be treated as a special case if it
     should be passed to these functions unpredictably.  Also, the
     pointer returned by these functions may be passed to subsequent
     invocations of realloc().


BUGS

     **** DMALLOC DOES NOT COMPLY WITH THE PARAGRAPH BELOW ****

     Since realloc() accepts a pointer to a block freed since the last
     call to malloc(), calloc() or realloc(), a degradation of
     performance results.  The semantics of free() should be changed
     so that the contents of a previously freed block are undefined.