diff options
author | Jerry Jelinek <jerry.jelinek@joyent.com> | 2017-07-31 13:00:21 +0000 |
---|---|---|
committer | Jerry Jelinek <jerry.jelinek@joyent.com> | 2017-07-31 13:00:21 +0000 |
commit | a43f1df58a9e20639c60ab24da9193c2ff8e074e (patch) | |
tree | 2c782258c5ed0ceff90367f775728dc5cb1e9a12 /usr/src/man/man3c | |
parent | 2b6211c70cd9e899b15e259d53790f01e46bb88a (diff) | |
parent | d65dfb0a6855414a1ff916b896e8be0fbe0d212a (diff) | |
download | illumos-joyent-a43f1df58a9e20639c60ab24da9193c2ff8e074e.tar.gz |
[illumos-gate merge]
commit d65dfb0a6855414a1ff916b896e8be0fbe0d212a
8499 ficl: this statement may fall through
commit e07d85f87c3920e032adb855fdc500e4616c7718
7875 libcurses: multiple misleading-indentation errors
commit f1cdbd3731f01314c1d46f05280ad63f1770fdc6
8546 want recallocarray(3C) and freezero(3C)
commit 0b905b49d460a57773d88d714cd880ffe0182b7c
5980 in-kernel inet_ntop should format IPv4 addresses like userland one
commit 3facafd61791b16f112797f1b07dde00ab6b9a59
8487 cfgadm_plugins/shp: memory leak in cfga_get_condition()
commit a3bcc60de108dc761615b2b9561d6dc76971f471
8543 nss_ldap crashes handling a group with no gidnumber attribute
commit b2ce6e4ebc262a57e5c5d0224b2577526261a0e4
8463 common/acl: 'resultcount' may be used uninitialized in this function
commit 83e86541459022f059e0bf50ebbc33fc8ec2d62e
8486 libdiskmgt: memory leak in slice_get_stats()
commit 7f6d142fc0001e76967b1f047b6df5bc4c5d9082
8399 sun_fc: in C++11 destructors default to noexcept
commit 3dde7c95de085cfe31f989eff6cefb775563eeb8
8528 Want Chelsio T6 support
Diffstat (limited to 'usr/src/man/man3c')
-rw-r--r-- | usr/src/man/man3c/Makefile | 4 | ||||
-rw-r--r-- | usr/src/man/man3c/malloc.3c | 108 |
2 files changed, 101 insertions, 11 deletions
diff --git a/usr/src/man/man3c/Makefile b/usr/src/man/man3c/Makefile index fc3bcc8bb6..b3387a412f 100644 --- a/usr/src/man/man3c/Makefile +++ b/usr/src/man/man3c/Makefile @@ -817,6 +817,7 @@ MANLINKS= FD_CLR.3c \ fputs.3c \ free.3c \ freelocale.3c \ + freezero.3c \ fscanf.3c \ fseeko.3c \ fsetattr.3c \ @@ -1141,6 +1142,7 @@ MANLINKS= FD_CLR.3c \ readdir_r.3c \ realloc.3c \ reallocarray.3c \ + recallocarray.3c \ regerror.3c \ regex.3c \ regexec.3c \ @@ -1940,9 +1942,11 @@ minor.3c := LINKSRC = makedev.3c alloca.3c := LINKSRC = malloc.3c calloc.3c := LINKSRC = malloc.3c free.3c := LINKSRC = malloc.3c +freezero.3c := LINKSRC = malloc.3c memalign.3c := LINKSRC = malloc.3c realloc.3c := LINKSRC = malloc.3c reallocarray.3c := LINKSRC = malloc.3c +recallocarray.3c := LINKSRC = malloc.3c valloc.3c := LINKSRC = malloc.3c mblen_l.3c := LINKSRC = mblen.3c diff --git a/usr/src/man/man3c/malloc.3c b/usr/src/man/man3c/malloc.3c index f0c69f02f5..79b7a6f4fa 100644 --- a/usr/src/man/man3c/malloc.3c +++ b/usr/src/man/man3c/malloc.3c @@ -17,17 +17,20 @@ .\" .\" Copyright 1989 AT&T .\" Copyright (c) 2005, Sun Microsystems, Inc. All Rights Reserved. +.\" Copyright 2017 Nexenta Systems, Inc. .\" -.Dd March 10, 2017 +.Dd July 28, 2017 .Dt MALLOC 3C .Os .Sh NAME .Nm malloc , .Nm calloc , .Nm free , +.Nm freezero , .Nm memalign , .Nm realloc , .Nm reallocarray , +.Nm recallocarray , .Nm valloc , .Nm alloca .Nd memory allocator @@ -46,6 +49,11 @@ .Fo free .Fa "void *ptr" .Fc +.Ft void +.Fo freezero +.Fa "void *ptr" +.Fa "size_t size" +.Fc .Ft void * .Fo memalign .Fa "size_t alignment" @@ -63,6 +71,13 @@ .Fa "size_t elsize" .Fc .Ft void * +.Fo recallocarray +.Fa "void *ptr" +.Fa "size_t oldnelem" +.Fa "size_t newnelem" +.Fa "size_t elsize" +.Fc +.Ft void * .Fo valloc .Fa "size_t size" .Fc @@ -92,8 +107,9 @@ is a pointer to a block previously allocated by .Fn malloc , .Fn calloc , .Fn realloc , +.Fn reallocarray , or -.Fn reallocarray . +.Fn recallocarray . After .Fn free is executed, this space is made available for further allocation by the @@ -107,6 +123,32 @@ If a random number is passed to the results are undefined. .Pp The +.Fn freezero +function is similar to the +.Fn free +function except it ensures memory is explicitly discarded. +If +.Fa ptr +is +.Dv NULL , +no action occurs. +If +.Fa ptr +is not +.Dv NULL , +the +.Fa size +argument must be equal or smaller than the size of the earlier allocation that +returned +.Fa ptr . +.Fn freezero +guarantees the memory range starting at +.Fa ptr +with length +.Fa size +is discarded while deallocating the whole object originally allocated. +.Pp +The .Fn calloc function allocates space for an array of .Fa nelem @@ -167,6 +209,30 @@ and checks for overflow in calculation. .Pp The +.Fn recallocarray +function is similar to +.Fn reallocarray +except it ensures newly allocated memory is cleared similar to +.Fn calloc . +If +.Fa ptr +is +.Dv NULL , +.Fa oldnelem +is ignored and the call is equivalent to +.Fn calloc . +If +.Fa ptr +is not +.Dv NULL , +.Fa oldnelem +must be a value such that +.Fa oldnelem Ns * Ns Fa elsize +is the size of the earlier allocation that returned +.Fa ptr , +otherwise the behaviour is undefined. +.Pp +The .Fn valloc function has the same effect as .Fn malloc , @@ -191,18 +257,17 @@ for storage of any type of object. .Pp If there is no available memory, .Fn malloc , +.Fn calloc , .Fn realloc , .Fn reallocarray , +.Fn recallocarray , .Fn memalign , -.Fn valloc , and -.Fn calloc +.Fn valloc return a null pointer. .Pp When .Fn realloc -or -.Fn reallocarray is called with .Fa size > 0 and returns @@ -223,14 +288,17 @@ If .Fn malloc , .Fn calloc , .Fn realloc , +.Fn reallocarray , or -.Fn reallocarray +.Fn recallocarray returns unsuccessfully, .Va errno will be set to indicate the error. The .Fn free -function does not set +and +.Fn freezero +functions do not set .Va errno . .Sh ERRORS The @@ -240,7 +308,7 @@ The and .Fn reallocarray functions will fail if: -.Bl -tag -width "ENOMEM" +.Bl -tag -width Er .It Er ENOMEM The physical limits of the system are exceeded by .Fa size @@ -251,6 +319,21 @@ There is not enough memory available to allocate .Fa size bytes of memory; but the application could try again later. .El +.Pp +The +.Fn recallocarray +function will fail if: +.Bl -tag -width Er +.It Er EINVAL +.Fa ptr +is not +.Dv NULL +and multiplying +.Fa oldnelem +and +.Fa elsize +results in integer overflow. +.El .Sh USAGE Portable applications should avoid using .Fn valloc @@ -298,8 +381,11 @@ functions are .Sy Standard. .Pp The -.Fn reallocarray -function is +.Fn freezero , +.Fn reallocarray , +and +.Fn recallocarray +functions are .Sy Committed . .Pp The |