summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib/malloc.3
diff options
context:
space:
mode:
authoraaron <>1999-06-29 18:36:24 +0000
committeraaron <>1999-06-29 18:36:24 +0000
commit5771e6280ed94b6457e5db9facb5899254e4fb7f (patch)
tree95397a7ed19a0cddf5a2ebb73dee20cf20fe2c29 /src/lib/libc/stdlib/malloc.3
parent403f5844d16c63a63b8ce33a354e4871cb93df4c (diff)
downloadopenbsd-5771e6280ed94b6457e5db9facb5899254e4fb7f.tar.gz
openbsd-5771e6280ed94b6457e5db9facb5899254e4fb7f.tar.bz2
openbsd-5771e6280ed94b6457e5db9facb5899254e4fb7f.zip
first round of repairs on stdlib
Diffstat (limited to 'src/lib/libc/stdlib/malloc.3')
-rw-r--r--src/lib/libc/stdlib/malloc.327
1 files changed, 14 insertions, 13 deletions
diff --git a/src/lib/libc/stdlib/malloc.3 b/src/lib/libc/stdlib/malloc.3
index 023a58b832..e7c237c63a 100644
--- a/src/lib/libc/stdlib/malloc.3
+++ b/src/lib/libc/stdlib/malloc.3
@@ -33,7 +33,7 @@
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE. 34.\" SUCH DAMAGE.
35.\" 35.\"
36.\" $OpenBSD: malloc.3,v 1.14 1999/05/27 20:49:35 aaron Exp $ 36.\" $OpenBSD: malloc.3,v 1.15 1999/06/29 18:36:21 aaron Exp $
37.\" 37.\"
38.Dd August 27, 1996 38.Dd August 27, 1996
39.Dt MALLOC 3 39.Dt MALLOC 3
@@ -113,9 +113,9 @@ If
113is a null pointer, the 113is a null pointer, the
114.Fn realloc 114.Fn realloc
115function behaves like the 115function behaves like the
116.Fn malloc 116.Fn malloc
117function for the specified size. 117function for the specified size.
118If the space cannot be allocated, the object 118If the space cannot be allocated, the object
119pointed to by 119pointed to by
120.Fa ptr 120.Fa ptr
121is unchanged. 121is unchanged.
@@ -137,7 +137,7 @@ if ((p = realloc(p, nsize)) == NULL)
137.Pp 137.Pp
138In most cases, this will result in a leak of memory. 138In most cases, this will result in a leak of memory.
139As stated earlier, a return value of 139As stated earlier, a return value of
140.Fa NULL 140.Dv NULL
141indicates that the old object still remains allocated. 141indicates that the old object still remains allocated.
142Better code looks like this: 142Better code looks like this:
143.Bd -literal -offset indent 143.Bd -literal -offset indent
@@ -163,7 +163,7 @@ Flags are single letters, uppercase means on, lowercase means off.
163``abort'' malloc will coredump the process, rather than tolerate failure. 163``abort'' malloc will coredump the process, rather than tolerate failure.
164This is a very handy debugging aid, since the core file will represent the 164This is a very handy debugging aid, since the core file will represent the
165time of failure, 165time of failure,
166rather than when the NULL pointer was accessed. 166rather than when the null pointer was accessed.
167.Pp 167.Pp
168.It D 168.It D
169``dump'' malloc will dump statistics in a file called ``malloc.out'' at exit. 169``dump'' malloc will dump statistics in a file called ``malloc.out'' at exit.
@@ -195,7 +195,7 @@ for all operations.
195Consult the source for this one. 195Consult the source for this one.
196.Pp 196.Pp
197.It X 197.It X
198``xmalloc'' 198``xmalloc''
199rather than return failure, 199rather than return failure,
200.Xr abort 3 200.Xr abort 3
201the program with a diagnostic message on stderr. 201the program with a diagnostic message on stderr.
@@ -244,15 +244,15 @@ The
244function a pointer to the possibly moved allocated space; 244function a pointer to the possibly moved allocated space;
245otherwise a null pointer is returned. 245otherwise a null pointer is returned.
246.Sh MESSAGES 246.Sh MESSAGES
247If 247If
248.Fn malloc , 248.Fn malloc ,
249.Fn free 249.Fn free
250or 250or
251.Fn realloc 251.Fn realloc
252detects an error or warning condition, 252detects an error or warning condition,
253a message will be printed to filedescriptor 253a message will be printed to filedescriptor
2542 (not using stdio). 2542 (not using stdio).
255Errors will always result in the process being 255Errors will always result in the process being
256.Xr abort 3 'ed. 256.Xr abort 3 'ed.
257If the ``A'' option has been specified, warnings will also 257If the ``A'' option has been specified, warnings will also
258.Xr abort 3 258.Xr abort 3
@@ -267,9 +267,10 @@ fishy in there. Consult sources and or wizards.
267``allocation failed'' 267``allocation failed''
268if the ``A'' option is specified it is an error for 268if the ``A'' option is specified it is an error for
269.Fn malloc 269.Fn malloc
270or 270or
271.Fn realloc 271.Fn realloc
272to return NULL. 272to return
273.Dv NULL .
273.Pp 274.Pp
274``mmap(2) failed, check limits.'' 275``mmap(2) failed, check limits.''
275This is a rather weird condition that is most likely to mean that 276This is a rather weird condition that is most likely to mean that
@@ -287,7 +288,7 @@ A pointer to a free chunk is attempted freed again.
287The pointer doesn't make sense. It's above the area of memory that 288The pointer doesn't make sense. It's above the area of memory that
288malloc knows something about. 289malloc knows something about.
289This could be a pointer from some 290This could be a pointer from some
290.Xr mmap 2 'ed 291.Xr mmap 2 'ed
291memory. 292memory.
292.Pp 293.Pp
293``junk pointer, too low to make sense.'' 294``junk pointer, too low to make sense.''
@@ -344,7 +345,7 @@ secondary.
344.Pp 345.Pp
345The main difference from other malloc implementations are believed to be that 346The main difference from other malloc implementations are believed to be that
346the free pages are not accessed until allocated. 347the free pages are not accessed until allocated.
347Most malloc implementations will store a data structure containing a, 348Most malloc implementations will store a data structure containing a,
348possibly double-, linked list in the free chunks of memory, used to tie 349possibly double-, linked list in the free chunks of memory, used to tie
349all the free memory together. 350all the free memory together.
350That is a quite suboptimal thing to do. 351That is a quite suboptimal thing to do.