Cider Isn't Darwin Emulation, Really
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335.\" Copyright (c) 2006 Apple Computer, Inc. All rights reserved..\".\" @APPLE_LICENSE_HEADER_START@.\".\" The contents of this file constitute Original Code as defined in and.\" are subject to the Apple Public Source License Version 1.1 (the.\" "License"). You may not use this file except in compliance with the.\" License. Please obtain a copy of the License at.\" http://www.apple.com/publicsource and read it before using this file..\".\" This Original Code and all software distributed under the License are.\" distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER.\" EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,.\" INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,.\" FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the.\" License for the specific language governing rights and limitations.\" under the License..\".\" @APPLE_LICENSE_HEADER_END@.\".Dd Aug 13, 2008.Dt MALLOC 3.Os.Sh NAME.Nm calloc ,.Nm free ,.Nm malloc ,.Nm realloc ,.Nm reallocf ,.Nm valloc ,.Nm aligned_alloc.Nd memory allocation.Sh SYNOPSIS.In stdlib.h.Ft void *.Fo calloc.Fa "size_t count".Fa "size_t size".Fc.Ft void.Fo free.Fa "void *ptr".Fc.Ft void *.Fo malloc.Fa "size_t size".Fc.Ft void *.Fo realloc.Fa "void *ptr".Fa "size_t size".Fc.Ft void *.Fo reallocf.Fa "void *ptr".Fa "size_t size".Fc.Ft void *.Fo valloc.Fa "size_t size".Fc.Ft void *.Fo aligned_alloc.Fa "size_t alignment".Fa "size_t size".Fc.Sh DESCRIPTIONThe.Fn malloc ,.Fn calloc ,.Fn valloc ,.Fn realloc ,and.Fn reallocffunctions allocate memory.The allocated memory is aligned such that it can be used for any data type,including AltiVec- and SSE-related types.The.Fn aligned_allocfunction allocates memory with the requested alignment.The.Fn freefunction frees allocations that were created via the preceding allocationfunctions..PpThe.Fn mallocfunction allocates.Fa sizebytes of memory and returns a pointer to the allocated memory..PpThe.Fn callocfunction contiguously allocates enough space for.Fa countobjects that are.Fa sizebytes of memory each and returns a pointer to the allocated memory.The allocated memory is filled with bytes of value zero..PpThe.Fn vallocfunction allocates.Fa sizebytes of memory and returns a pointer to the allocated memory.The allocated memory is aligned on a page boundary..PpThe.Fn aligned_allocfunction allocates.Fa sizebytes of memory with an alignment specified by.Fa alignmentand returns a pointer to the allocated memory..PpThe.Fn reallocfunction tries to change the size of the allocation pointed to by.Fa ptrto.Fa size ,and returns.Fa ptr .If there is not enough room to enlarge the memory allocation pointed to by.Fa ptr ,.Fn realloccreates a new allocation, copies as much of the old data pointed to by.Fa ptras will fit to the new allocation, frees the old allocation, and returns apointer to the allocated memory.If.Fa ptris .Dv NULL ,.Fn reallocis identical to a call to .Fn mallocfor .Fa sizebytes.If.Fa sizeis zero and .Fa ptris not .Dv NULL ,a new, minimum sized object is allocated and the original object is freed.When extending a region allocated with calloc(3), realloc(3) does not guarantee that the additional memory is also zero-filled..PpThe.Fn reallocffunction is identical to the.Fn reallocfunction, except that itwill free the passed pointer when the requested memory cannot be allocated.This is a.Fxspecific API designed to ease the problems with traditional coding stylesfor realloc causing memory leaks in libraries..PpThe.Fn freefunction deallocates the memory allocation pointed to by.Fa ptr . If.Fa ptr is a NULL pointer, no operation is performed..Sh RETURN VALUESIf successful,.Fn calloc ,.Fn malloc ,.Fn realloc ,.Fn reallocf ,.Fn valloc ,and.Fn aligned_allocfunctions return a pointer to allocated memory.If there is an error, they return a.Dv NULLpointer and set.Va errnoto.Er ENOMEM ..PpIn addition,.Fn aligned_allocreturns a.Dv NULLpointer and sets.Va errnoto.Er EINVALif.Fa sizeis not an integral multiple of.Fa alignment ,or if.Fa alignmentis not a power of 2 at least as large as.Fn sizeof "void *" ..PpFor.Fn realloc ,the input pointer is still valid if reallocation failed.For.Fn reallocf ,the input pointer will have been freed if reallocation failed..PpThe.Fn freefunction does not return a value..Sh DEBUGGING ALLOCATION ERRORSA number of facilities are provided to aid in debugging allocation errors inapplications.These facilities are primarily controlled via environment variables.The recognized environment variables and their meanings are documented below..Sh ENVIRONMENTThe following environment variables change the behavior of theallocation-related functions..Bl -tag -width ".Ev MallocStackLoggingNoCompact".It Ev MallocDebugReportIf set, specifies where messages are written. Set to "stderr" to write messagesto the standard error stream, "none" to discard all messages and "crash" towrite messages to standard error only for a condition that is about to cause acrash. When not set, message are written to the standard error stream if itappears to be a terminal (that is, if isatty(STDERR_FILENO) returns a non-zerovalue) and are otherwise discarded..It Ev MallocGuardEdgesIf set, add a guard page before and after each large block..It Ev MallocDoNotProtectPreludeIf set, do not add a guard page before large blocks,even if the.Ev MallocGuardEdgesenvironment variable is set..It Ev MallocDoNotProtectPostludeIf set, do not add a guard page after large blocks,even if the.Ev MallocGuardEdgesenvironment variable is set..It Ev MallocStackLoggingThe default behavior if this is set is to record all allocation and deallocation events to an on-disk log, along with stacks, so that tools like.Xr leaks 1and.Xr malloc_history 1can be used..PpSet to "vm" to record only allocation of virtual memory regions allocated by system calls and mach traps, such as by.Xr mmap 1..PpSet to "malloc" to record only allocations via.Xr malloc 3and related interfaces, not virtual memory regions..PpSet to "lite" to record current allocations only, not history. These are recorded by in-memory data structures, instead of an on-disk log..It Ev MallocStackLoggingNoCompactIf set, record all stacks in a manner that is compatible with the.Nm malloc_historyprogram..It Ev MallocStackLoggingDirectoryIf set, records stack logs to the directory specified instead of saving them to the default location (/tmp)..It Ev MallocScribbleIf set, fill memory that has been allocated with 0xaa bytes.This increases the likelihood that a program making assumptions about the contents offreshly allocated memory will fail.Also if set, fill memory that has been deallocated with 0x55 bytes.This increases the likelihood that a program will fail due to accessing memorythat is no longer allocated. Note that due to the way in which freed memory ismanaged internally, the 0x55 pattern may not appear in some parts of adeallocated memory block..It Ev MallocCheckHeapStart <s>If set, specifies the number of allocations.Fa <s>to wait before begining periodic heap checks every.Fa <n>as specified by .Ev MallocCheckHeapEach .If.Ev MallocCheckHeapStartis set but .Ev MallocCheckHeapEachis not specified, the default check repetition is 1000..It Ev MallocCheckHeapEach <n>If set, run a consistency check on the heap every.Fa <n>operations..Ev MallocCheckHeapEachis only meaningful if.Ev MallocCheckHeapStartis also set..It Ev MallocCheckHeapSleep <t>Sets the number of seconds to sleep (waiting for a debugger to attach) when.Ev MallocCheckHeapStartis set and a heap corruption is detected.The default is 100 seconds.Setting this to zero means not to sleep at all.Setting this to a negative number means to sleep (for the positive number ofseconds) only the very first time a heap corruption is detected..It Ev MallocCheckHeapAbort <b>When.Ev MallocCheckHeapStartis set and this is set to a non-zero value, causes.Xr abort 3to be called if a heap corruption is detected, instead of any sleeping..It Ev MallocErrorAbortIf set, causes.Xr abort 3to be called if an error was encountered in.Xr malloc 3or .Xr free 3, such as a calling.Xr free 3on a pointer previously freed..It Ev MallocCorruptionAbortSimilar to.Ev MallocErrorAbort but will not abort in out of memory conditions, making it more useful to catchonly those errors which will cause memory corruption.MallocCorruptionAbort is always set on 64-bit processes..It Ev MallocHelpIf set, print a list of environment variables that are paid heed to by theallocation-related functions, along with short descriptions.The list should correspond to this documentation..El.Sh DIAGNOSTIC MESSAGES.Sh SEE ALSO.Xr leaks 1 ,.Xr malloc_history 1 ,.Xr abort 3 ,.Xr malloc_size 3 ,.Xr malloc_zone_malloc 3 ,.Xr posix_memalign 3 ,.Xr libgmalloc 3