diff options
| author | millert <> | 2007-09-03 14:37:02 +0000 |
|---|---|---|
| committer | millert <> | 2007-09-03 14:37:02 +0000 |
| commit | 2056049ed6b7a028e611838a742280fced6d2c23 (patch) | |
| tree | e20e18fc5434b1b49708f65ad179f4ae2602951b /src/lib/libc/stdlib/malloc.3 | |
| parent | 6fdd2cf23672d7bc626fee11d4ca588e6882a436 (diff) | |
| download | openbsd-2056049ed6b7a028e611838a742280fced6d2c23.tar.gz openbsd-2056049ed6b7a028e611838a742280fced6d2c23.tar.bz2 openbsd-2056049ed6b7a028e611838a742280fced6d2c23.zip | |
add recaloc(3)
Diffstat (limited to 'src/lib/libc/stdlib/malloc.3')
| -rw-r--r-- | src/lib/libc/stdlib/malloc.3 | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/lib/libc/stdlib/malloc.3 b/src/lib/libc/stdlib/malloc.3 index 35f83a0c24..4c5ea84c08 100644 --- a/src/lib/libc/stdlib/malloc.3 +++ b/src/lib/libc/stdlib/malloc.3 | |||
| @@ -30,15 +30,16 @@ | |||
| 30 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 30 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 31 | .\" SUCH DAMAGE. | 31 | .\" SUCH DAMAGE. |
| 32 | .\" | 32 | .\" |
| 33 | .\" $OpenBSD: malloc.3,v 1.47 2007/08/08 21:24:29 millert Exp $ | 33 | .\" $OpenBSD: malloc.3,v 1.48 2007/09/03 14:37:02 millert Exp $ |
| 34 | .\" | 34 | .\" |
| 35 | .Dd $Mdocdate: August 8 2007 $ | 35 | .Dd $Mdocdate: September 3 2007 $ |
| 36 | .Dt MALLOC 3 | 36 | .Dt MALLOC 3 |
| 37 | .Os | 37 | .Os |
| 38 | .Sh NAME | 38 | .Sh NAME |
| 39 | .Nm malloc , | 39 | .Nm malloc , |
| 40 | .Nm calloc , | 40 | .Nm calloc , |
| 41 | .Nm realloc , | 41 | .Nm realloc , |
| 42 | .Nm recalloc , | ||
| 42 | .Nm free , | 43 | .Nm free , |
| 43 | .Nm cfree | 44 | .Nm cfree |
| 44 | .Nd memory allocation and deallocation | 45 | .Nd memory allocation and deallocation |
| @@ -50,6 +51,8 @@ | |||
| 50 | .Fn calloc "size_t nmemb" "size_t size" | 51 | .Fn calloc "size_t nmemb" "size_t size" |
| 51 | .Ft void * | 52 | .Ft void * |
| 52 | .Fn realloc "void *ptr" "size_t size" | 53 | .Fn realloc "void *ptr" "size_t size" |
| 54 | .Ft void * | ||
| 55 | .Fn recalloc "void *ptr" "size_t nmemb" "size_t size" | ||
| 53 | .Ft void | 56 | .Ft void |
| 54 | .Fn free "void *ptr" | 57 | .Fn free "void *ptr" |
| 55 | .Ft void | 58 | .Ft void |
| @@ -203,7 +206,18 @@ if ((newp = realloc(p, num * size)) == NULL) { | |||
| 203 | ... | 206 | ... |
| 204 | .Ed | 207 | .Ed |
| 205 | .Pp | 208 | .Pp |
| 206 | Malloc will first look for a symbolic link called | 209 | The |
| 210 | .Fn recalloc | ||
| 211 | function is similar to | ||
| 212 | .Fn realloc | ||
| 213 | except that it shares semantics with | ||
| 214 | .Fn calloc | ||
| 215 | rather than | ||
| 216 | .Fn malloc . | ||
| 217 | Newly allocated space is initialized to zero and the resulting size is | ||
| 218 | checked for integer overflow. | ||
| 219 | .Pp | ||
| 220 | These functions will first look for a symbolic link called | ||
| 207 | .Pa /etc/malloc.conf | 221 | .Pa /etc/malloc.conf |
| 208 | and next check the environment for a variable called | 222 | and next check the environment for a variable called |
| 209 | .Ev MALLOC_OPTIONS | 223 | .Ev MALLOC_OPTIONS |
| @@ -258,6 +272,8 @@ sizeof(ptr) errors where sizeof(*ptr) is meant. | |||
| 258 | .Dq realloc . | 272 | .Dq realloc . |
| 259 | Always reallocate when | 273 | Always reallocate when |
| 260 | .Fn realloc | 274 | .Fn realloc |
| 275 | or | ||
| 276 | .Fn recalloc | ||
| 261 | is called, even if the initial allocation was big enough. | 277 | is called, even if the initial allocation was big enough. |
| 262 | This can substantially aid in compacting memory. | 278 | This can substantially aid in compacting memory. |
| 263 | .\".Pp | 279 | .\".Pp |
| @@ -440,6 +456,12 @@ The | |||
| 440 | .Fn malloc | 456 | .Fn malloc |
| 441 | function conforms to | 457 | function conforms to |
| 442 | .St -ansiC . | 458 | .St -ansiC . |
| 459 | .Pp | ||
| 460 | The | ||
| 461 | .Fn recalloc | ||
| 462 | function is an | ||
| 463 | .Ox | ||
| 464 | extension. | ||
| 443 | .Sh HISTORY | 465 | .Sh HISTORY |
| 444 | The present implementation of | 466 | The present implementation of |
| 445 | .Fn malloc | 467 | .Fn malloc |
