diff options
author | Richard Lowe <richlowe@richlowe.net> | 2011-03-14 14:05:30 -0400 |
---|---|---|
committer | Richard Lowe <richlowe@richlowe.net> | 2011-03-14 14:05:30 -0400 |
commit | c10c16dec587a0662068f6e2991c29ed3a9db943 (patch) | |
tree | f414286f4bba41d75683ed4fbbaa6bfa4bf7fabd /usr/src/man/man3malloc/bsdmalloc.3malloc | |
parent | 68caef18a23a498d9e3017b983562c0f4fd8ab23 (diff) | |
download | illumos-gate-c10c16dec587a0662068f6e2991c29ed3a9db943.tar.gz |
243 system manual pages should live with the software
Reviewed by: garrett@nexenta.com
Reviewed by: gwr@nexenta.com
Reviewed by: trisk@opensolaris.org
Approved by: gwr@nexenta.com
--HG--
extra : rebase_source : 0c599d0bec0dc8865fbba67721a7a6cd6b1feefb
Diffstat (limited to 'usr/src/man/man3malloc/bsdmalloc.3malloc')
-rw-r--r-- | usr/src/man/man3malloc/bsdmalloc.3malloc | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/usr/src/man/man3malloc/bsdmalloc.3malloc b/usr/src/man/man3malloc/bsdmalloc.3malloc new file mode 100644 index 0000000000..4b00266f4d --- /dev/null +++ b/usr/src/man/man3malloc/bsdmalloc.3malloc @@ -0,0 +1,117 @@ +'\" te +.\" Copyright (c) 2005, Sun Microsystems, Inc. All Rights Reserved. +.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. +.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. +.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] +.TH bsdmalloc 3MALLOC "21 Mar 2005" "SunOS 5.11" "Memory Allocation Library Functions" +.SH NAME +bsdmalloc \- memory allocator +.SH SYNOPSIS +.LP +.nf +\fBcc\fR [ \fIflag\fR ... ] \fIfile\fR ... \fB-lbsdmalloc\fR [ \fIlibrary\fR ... ] + +\fBchar *\fR\fBmalloc\fR(\fB\fR\fIsize\fRunsigned \fIsize\fR; +.fi + +.LP +.nf +\fBint\fR \fBfree\fR(\fB\fR \fIptr\fRchar *\fIptr\fR; +.fi + +.LP +.nf +\fBchar *\fR\fBrealloc\fR(\fB\fR \fIptr\fR, \fB\fR\fIsize\fRchar *\fIptr\fR; +unsigned \fIsize\fR; +.fi + +.SH DESCRIPTION +.sp +.LP +These routines provide a general-purpose memory allocation package. They +maintain a table of free blocks for efficient allocation and coalescing of free +storage. When there is no suitable space already free, the allocation routines +call \fBsbrk\fR(2) to get more memory from the system. Each of the allocation +routines returns a pointer to space suitably aligned for storage of any type +of object. Each returns a null pointer if the request cannot be completed. +.sp +.LP +The \fBmalloc()\fR function returns a pointer to a block of at least +\fIsize\fR bytes, which is appropriately aligned. +.sp +.LP +The \fBfree()\fR function releases a previously allocated block. Its argument +is a pointer to a block previously allocated by \fBmalloc()\fR or +\fBrealloc()\fR. The \fBfree()\fR function does not set \fBerrno\fR. +.sp +.LP +The \fBrealloc()\fR function changes the size of the block pointed to by +\fIptr\fR to \fIsize\fR bytes and returns a pointer to the (possibly moved) +block. The contents will be unchanged up to the lesser of the new and old +sizes. If the new size of the block requires movement of the block, the space +for the previous instantiation of the block is freed. If the new size is +larger, the contents of the newly allocated portion of the block are +unspecified. If \fIptr\fR is \fINULL\fR, \fBrealloc()\fR behaves like +\fBmalloc()\fR for the specified size. If \fIsize\fR is 0 and \fIptr\fR is not +a null pointer, the space pointed to is freed. +.SH RETURN VALUES +.sp +.LP +The \fBmalloc()\fR and \fBrealloc()\fR functions return a null pointer if there +is not enough available memory. They return a non-null pointer if \fIsize\fR +is 0. These pointers should not be dereferenced. When \fBrealloc()\fR returns +\fINULL\fR, the block pointed to by \fIptr\fR is left intact. Always cast the +value returned by \fBmalloc()\fR and \fBrealloc()\fR. +.SH ERRORS +.sp +.LP +If \fBmalloc()\fR or \fBrealloc()\fR returns unsuccessfully, \fBerrno\fR will +be set to indicate the following: +.sp +.ne 2 +.mk +.na +\fB\fBENOMEM\fR\fR +.ad +.RS 10n +.rt +\fIsize\fR bytes of memory cannot be allocated because it exceeds the physical +limits of the system. +.RE + +.sp +.ne 2 +.mk +.na +\fB\fBEAGAIN\fR\fR +.ad +.RS 10n +.rt +There is not enough memory available at this point in time to allocate +\fIsize\fR bytes of memory; but the application could try again later. +.RE + +.SH USAGE +.sp +.LP +Using \fBrealloc()\fR with a block freed before the most recent call to +\fBmalloc()\fR or \fBrealloc()\fR results in an error. +.sp +.LP +Comparative features of the various allocation libraries can be found in the +\fBumem_alloc\fR(3MALLOC) manual page. +.SH SEE ALSO +.sp +.LP +\fBbrk\fR(2), \fBmalloc\fR(3C), \fBmalloc\fR(3MALLOC), +\fBmapmalloc\fR(3MALLOC), \fBumem_alloc\fR(3MALLOC) +.SH WARNINGS +.sp +.LP +Use of \fBlibbsdmalloc\fR renders an application non-SCD compliant. +.sp +.LP +The \fBlibbsdmalloc\fR routines are incompatible with the memory allocation +routines in the standard C-library (libc): \fBmalloc\fR(3C), \fBalloca\fR(3C), +\fBcalloc\fR(3C), \fBfree\fR(3C), \fBmemalign\fR(3C), \fBrealloc\fR(3C), and +\fBvalloc\fR(3C). |