1bsdmalloc(3MALLOC)    Memory Allocation Library Functions   bsdmalloc(3MALLOC)
2
3
4

NAME

6       bsdmalloc - memory allocator
7

SYNOPSIS

9       cc [ flag ... ] file ... -lbsdmalloc [ library ... ]
10
11       char *malloc(sizeunsigned size;
12
13
14       int free( ptrchar *ptr;
15
16
17       char *realloc( ptr, sizechar *ptr;
18       unsigned size;
19
20

DESCRIPTION

22       These  routines  provide  a  general-purpose memory allocation package.
23       They maintain a table of free blocks for efficient allocation and  coa‐
24       lescing  of free storage. When there is no suitable space already free,
25       the allocation routines call sbrk(2) to get more memory from  the  sys‐
26       tem. Each of the allocation routines returns a pointer  to  space suit‐
27       ably aligned for storage of any type of object.  Each  returns  a  null
28       pointer if the request cannot be completed.
29
30
31       The  malloc()  function  returns a pointer to  a block of at least size
32       bytes, which is appropriately aligned.
33
34
35       The free() function releases a previously allocated block. Its argument
36       is  a pointer to a block previously allocated by malloc() or realloc().
37       The free() function does not set errno.
38
39
40       The realloc() function changes the size of the block pointed to by  ptr
41       to  size bytes and returns a pointer to the (possibly moved) block. The
42       contents will be unchanged up to the lesser of the new and  old  sizes.
43       If  the new size of the block requires movement of the block, the space
44       for the previous instantiation of the block is freed. If the  new  size
45       is larger, the contents of the newly allocated portion of the block are
46       unspecified. If ptr is NULL, realloc() behaves like  malloc()  for  the
47       specified  size.  If size is 0 and ptr is not a null pointer, the space
48       pointed to is freed.
49

RETURN VALUES

51       The malloc() and realloc() functions return a null pointer if there  is
52       not enough available memory. They  return a non-null pointer if size is
53       0. These pointers should not be dereferenced.  When  realloc()  returns
54       NULL, the block pointed to by ptr is left intact. Always cast the value
55       returned by malloc() and realloc().
56

ERRORS

58       If malloc() or realloc() returns  unsuccessfully, errno will be set  to
59       indicate the following:
60
61       ENOMEM    size  bytes  of memory cannot be allocated because it exceeds
62                 the physical limits of the system.
63
64
65       EAGAIN    There is not enough memory available at this point in time to
66                 allocate  size bytes of memory; but the application could try
67                 again later.
68
69

USAGE

71       Using realloc() with a block freed before the most recent call to  mal‐
72       loc() or realloc() results in an error.
73
74
75       Comparative  features  of the various allocation libraries can be found
76       in the umem_alloc(3MALLOC) manual page.
77

SEE ALSO

79       brk(2),      malloc(3C),      malloc(3MALLOC),      mapmalloc(3MALLOC),
80       umem_alloc(3MALLOC)
81

WARNINGS

83       Use of libbsdmalloc renders an application non-SCD compliant.
84
85
86       The  libbsdmalloc  routines are incompatible with the memory allocation
87       routines in the standard C-library (libc): malloc(3C), alloca(3C), cal‐
88       loc(3C), free(3C), memalign(3C), realloc(3C), and  valloc(3C).
89
90
91
92SunOS 5.11                        21 Mar 2005               bsdmalloc(3MALLOC)
Impressum