diff options
| -rw-r--r-- | man3/malloc.3 | 73 |
1 files changed, 39 insertions, 34 deletions
diff --git a/man3/malloc.3 b/man3/malloc.3 index 8f86849c55..0d346f2c1b 100644 --- a/man3/malloc.3 +++ b/man3/malloc.3 @@ -25,42 +25,23 @@ .\" Documented MALLOC_CHECK_, Wolfram Gloger (wmglo@dent.med.uni-muenchen.de) .\" 2007-09-15 mtk: added notes on malloc()'s use of sbrk() and mmap(). .\" -.TH MALLOC 3 2009-01-13 "GNU" "Linux Programmer's Manual" +.TH MALLOC 3 2010-10-02 "GNU" "Linux Programmer's Manual" .SH NAME -calloc, malloc, free, realloc \- Allocate and free dynamic memory +malloc, free, calloc, realloc \- Allocate and free dynamic memory .SH SYNOPSIS .nf .B #include <stdlib.h> .sp -.BI "void *calloc(size_t " "nmemb" ", size_t " "size" ); -.br .BI "void *malloc(size_t " "size" ); -.br .BI "void free(void " "*ptr" ); -.br .BI "void *realloc(void " "*ptr" ", size_t " "size" ); +.BI "void *calloc(size_t " "nmemb" ", size_t " "size" ); .fi .SH DESCRIPTION -.BR calloc () -allocates memory for an array of -.I nmemb -elements of -.I size -bytes each and returns a pointer to the allocated memory. -The memory is set to zero. -If -.I nmemb -or -.I size -is 0, then -.BR calloc () -returns either NULL, -.\" glibc does this: -or a unique pointer value that can later be successfully passed to -.BR free (). .PP +The .BR malloc () -allocates +function allocates .I size bytes and returns a pointer to the allocated memory. The memory is not cleared. @@ -73,8 +54,9 @@ returns either NULL, or a unique pointer value that can later be successfully passed to .BR free (). .PP +The .BR free () -frees the memory space pointed to by +function frees the memory space pointed to by .IR ptr , which must have been returned by a previous call to .BR malloc (), @@ -88,13 +70,34 @@ If .I ptr is NULL, no operation is performed. .PP +The +.BR calloc () +function allocates memory for an array of +.I nmemb +elements of +.I size +bytes each and returns a pointer to the allocated memory. +The memory is set to zero. +If +.I nmemb +or +.I size +is 0, then +.BR calloc () +returns either NULL, +.\" glibc does this: +or a unique pointer value that can later be successfully passed to +.BR free (). +.PP +The .BR realloc () -changes the size of the memory block pointed to by +function changes the size of the memory block pointed to by .I ptr to .I size bytes. -The contents will be unchanged to the minimum of the old and new sizes; +The contents will be unchanged n the range from the start of the region +up to the minimum of the old and new sizes; newly allocated memory will be uninitialized. If .I ptr @@ -120,12 +123,12 @@ If the area pointed to was moved, a .I free(ptr) is done. .SH "RETURN VALUE" -For -.BR calloc () +The +.BR malloc () and -.BR malloc (), -return a pointer to the allocated memory, which is suitably -aligned for any kind of variable. +.BR calloc () +functions return a pointer to the allocated memory +that is suitably aligned for any kind of variable. On error, these functions return NULL. NULL may also be returned by a successful call to .BR malloc () @@ -140,11 +143,13 @@ or .I size equal to zero. .PP +The .BR free () -returns no value. +function returns no value. .PP +The .BR realloc () -returns a pointer to the newly allocated memory, which is suitably +function returns a pointer to the newly allocated memory, which is suitably aligned for any kind of variable and may be different from .IR ptr , or NULL if the request fails. |
