|
Lines 36-46
Link Here
|
| 36 |
.\" @(#)malloc.3 8.1 (Berkeley) 6/4/93 |
36 |
.\" @(#)malloc.3 8.1 (Berkeley) 6/4/93 |
| 37 |
.\" $FreeBSD: src/lib/libc/stdlib/malloc.3,v 1.63 2005/01/20 09:17:04 ru Exp $ |
37 |
.\" $FreeBSD: src/lib/libc/stdlib/malloc.3,v 1.63 2005/01/20 09:17:04 ru Exp $ |
| 38 |
.\" |
38 |
.\" |
| 39 |
.Dd August 19, 2004 |
39 |
.Dd October 16, 2005 |
| 40 |
.Dt MALLOC 3 |
40 |
.Dt MALLOC 3 |
| 41 |
.Os |
41 |
.Os |
| 42 |
.Sh NAME |
42 |
.Sh NAME |
| 43 |
.Nm malloc , calloc , realloc , free , reallocf |
43 |
.Nm malloc , calloc , realloc , free , reallocf , posix_memalign |
| 44 |
.Nd general purpose memory allocation functions |
44 |
.Nd general purpose memory allocation functions |
| 45 |
.Sh LIBRARY |
45 |
.Sh LIBRARY |
| 46 |
.Lb libc |
46 |
.Lb libc |
|
Lines 54-59
Link Here
|
| 54 |
.Fn realloc "void *ptr" "size_t size" |
54 |
.Fn realloc "void *ptr" "size_t size" |
| 55 |
.Ft void * |
55 |
.Ft void * |
| 56 |
.Fn reallocf "void *ptr" "size_t size" |
56 |
.Fn reallocf "void *ptr" "size_t size" |
|
|
57 |
.Ft int |
| 58 |
.Fn posix_memalign "void **ptr" "size_t alignment" "size_t size" |
| 57 |
.Ft void |
59 |
.Ft void |
| 58 |
.Fn free "void *ptr" |
60 |
.Fn free "void *ptr" |
| 59 |
.Ft const char * |
61 |
.Ft const char * |
|
Lines 148-153
Link Here
|
| 148 |
for realloc causing memory leaks in libraries. |
150 |
for realloc causing memory leaks in libraries. |
| 149 |
.Pp |
151 |
.Pp |
| 150 |
The |
152 |
The |
|
|
153 |
.Fn posix_memalign |
| 154 |
function allocates |
| 155 |
.Fa size |
| 156 |
bytes aligned on a boundary specified by |
| 157 |
.Fa alignment |
| 158 |
and places the address of the allocated memory in |
| 159 |
.Fa ptr . |
| 160 |
The value of |
| 161 |
.Fa alignment |
| 162 |
must be a power of two and a multiple of |
| 163 |
.Fn sizeof "void *" . |
| 164 |
.Pp |
| 165 |
The |
| 151 |
.Fn free |
166 |
.Fn free |
| 152 |
function causes the allocated memory referenced by |
167 |
function causes the allocated memory referenced by |
| 153 |
.Fa ptr |
168 |
.Fa ptr |
|
Lines 276-281
Link Here
|
| 276 |
.Er ENOMEM . |
291 |
.Er ENOMEM . |
| 277 |
.Pp |
292 |
.Pp |
| 278 |
The |
293 |
The |
|
|
294 |
.Fn posix_memalign |
| 295 |
function returns zero on success, |
| 296 |
.Er EINVAL |
| 297 |
if the |
| 298 |
.Fa alignment |
| 299 |
parameter was not a power of two, or was not a multiple of |
| 300 |
.Fn sizeof "void *" . |
| 301 |
Note that |
| 302 |
.Va errno |
| 303 |
is not set. |
| 304 |
.Pp |
| 305 |
The |
| 279 |
.Fn realloc |
306 |
.Fn realloc |
| 280 |
and |
307 |
and |
| 281 |
.Fn reallocf |
308 |
.Fn reallocf |
|
Lines 363-369
Link Here
|
| 363 |
If |
390 |
If |
| 364 |
.Fn malloc , |
391 |
.Fn malloc , |
| 365 |
.Fn calloc , |
392 |
.Fn calloc , |
| 366 |
.Fn realloc |
393 |
.Fn realloc , |
|
|
394 |
.Fn posix_memalign |
| 367 |
or |
395 |
or |
| 368 |
.Fn free |
396 |
.Fn free |
| 369 |
detect an error or warning condition, |
397 |
detect an error or warning condition, |
|
Lines 480-485
Link Here
|
| 480 |
.Fn free |
508 |
.Fn free |
| 481 |
functions conform to |
509 |
functions conform to |
| 482 |
.St -isoC . |
510 |
.St -isoC . |
|
|
511 |
.Pp |
| 512 |
The |
| 513 |
.Fn posix_memalign |
| 514 |
function conforms to |
| 515 |
.St -p1003.1-2001 . |
| 483 |
.Sh HISTORY |
516 |
.Sh HISTORY |
| 484 |
The present allocation implementation started out as a file system for a |
517 |
The present allocation implementation started out as a file system for a |
| 485 |
drum attached to a 20bit binary challenged computer which was built |
518 |
drum attached to a 20bit binary challenged computer which was built |
|
Lines 493-500
Link Here
|
| 493 |
.Fn reallocf |
526 |
.Fn reallocf |
| 494 |
function first appeared in |
527 |
function first appeared in |
| 495 |
.Fx 3.0 . |
528 |
.Fx 3.0 . |
|
|
529 |
.Pp |
| 530 |
The |
| 531 |
.Fn posix_memalign |
| 532 |
function first appeared in |
| 533 |
.Fx 7.0 . |
| 496 |
.Sh AUTHORS |
534 |
.Sh AUTHORS |
| 497 |
.An Poul-Henning Kamp Aq phk@FreeBSD.org |
535 |
.An Poul-Henning Kamp Aq phk@FreeBSD.org |
|
|
536 |
.Pp |
| 537 |
The |
| 538 |
.Fn posix_memalign |
| 539 |
function was added by |
| 540 |
.An Sergey Matveychuk Aq sem@FreeBSD.org |
| 498 |
.Sh BUGS |
541 |
.Sh BUGS |
| 499 |
The messages printed in case of problems provide no detail about the |
542 |
The messages printed in case of problems provide no detail about the |
| 500 |
actual values. |
543 |
actual values. |