diff options
Diffstat (limited to 'src/lib/libc/stdlib/malloc.3')
-rw-r--r-- | src/lib/libc/stdlib/malloc.3 | 27 |
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 | |||
113 | is a null pointer, the | 113 | is a null pointer, the |
114 | .Fn realloc | 114 | .Fn realloc |
115 | function behaves like the | 115 | function behaves like the |
116 | .Fn malloc | 116 | .Fn malloc |
117 | function for the specified size. | 117 | function for the specified size. |
118 | If the space cannot be allocated, the object | 118 | If the space cannot be allocated, the object |
119 | pointed to by | 119 | pointed to by |
120 | .Fa ptr | 120 | .Fa ptr |
121 | is unchanged. | 121 | is unchanged. |
@@ -137,7 +137,7 @@ if ((p = realloc(p, nsize)) == NULL) | |||
137 | .Pp | 137 | .Pp |
138 | In most cases, this will result in a leak of memory. | 138 | In most cases, this will result in a leak of memory. |
139 | As stated earlier, a return value of | 139 | As stated earlier, a return value of |
140 | .Fa NULL | 140 | .Dv NULL |
141 | indicates that the old object still remains allocated. | 141 | indicates that the old object still remains allocated. |
142 | Better code looks like this: | 142 | Better 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. |
164 | This is a very handy debugging aid, since the core file will represent the | 164 | This is a very handy debugging aid, since the core file will represent the |
165 | time of failure, | 165 | time of failure, |
166 | rather than when the NULL pointer was accessed. | 166 | rather 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. | |||
195 | Consult the source for this one. | 195 | Consult the source for this one. |
196 | .Pp | 196 | .Pp |
197 | .It X | 197 | .It X |
198 | ``xmalloc'' | 198 | ``xmalloc'' |
199 | rather than return failure, | 199 | rather than return failure, |
200 | .Xr abort 3 | 200 | .Xr abort 3 |
201 | the program with a diagnostic message on stderr. | 201 | the program with a diagnostic message on stderr. |
@@ -244,15 +244,15 @@ The | |||
244 | function a pointer to the possibly moved allocated space; | 244 | function a pointer to the possibly moved allocated space; |
245 | otherwise a null pointer is returned. | 245 | otherwise a null pointer is returned. |
246 | .Sh MESSAGES | 246 | .Sh MESSAGES |
247 | If | 247 | If |
248 | .Fn malloc , | 248 | .Fn malloc , |
249 | .Fn free | 249 | .Fn free |
250 | or | 250 | or |
251 | .Fn realloc | 251 | .Fn realloc |
252 | detects an error or warning condition, | 252 | detects an error or warning condition, |
253 | a message will be printed to filedescriptor | 253 | a message will be printed to filedescriptor |
254 | 2 (not using stdio). | 254 | 2 (not using stdio). |
255 | Errors will always result in the process being | 255 | Errors will always result in the process being |
256 | .Xr abort 3 'ed. | 256 | .Xr abort 3 'ed. |
257 | If the ``A'' option has been specified, warnings will also | 257 | If 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'' |
268 | if the ``A'' option is specified it is an error for | 268 | if the ``A'' option is specified it is an error for |
269 | .Fn malloc | 269 | .Fn malloc |
270 | or | 270 | or |
271 | .Fn realloc | 271 | .Fn realloc |
272 | to return NULL. | 272 | to return |
273 | .Dv NULL . | ||
273 | .Pp | 274 | .Pp |
274 | ``mmap(2) failed, check limits.'' | 275 | ``mmap(2) failed, check limits.'' |
275 | This is a rather weird condition that is most likely to mean that | 276 | This 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. | |||
287 | The pointer doesn't make sense. It's above the area of memory that | 288 | The pointer doesn't make sense. It's above the area of memory that |
288 | malloc knows something about. | 289 | malloc knows something about. |
289 | This could be a pointer from some | 290 | This could be a pointer from some |
290 | .Xr mmap 2 'ed | 291 | .Xr mmap 2 'ed |
291 | memory. | 292 | memory. |
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 |
345 | The main difference from other malloc implementations are believed to be that | 346 | The main difference from other malloc implementations are believed to be that |
346 | the free pages are not accessed until allocated. | 347 | the free pages are not accessed until allocated. |
347 | Most malloc implementations will store a data structure containing a, | 348 | Most malloc implementations will store a data structure containing a, |
348 | possibly double-, linked list in the free chunks of memory, used to tie | 349 | possibly double-, linked list in the free chunks of memory, used to tie |
349 | all the free memory together. | 350 | all the free memory together. |
350 | That is a quite suboptimal thing to do. | 351 | That is a quite suboptimal thing to do. |