Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
MALLOC.3
Upload User: jnzhq888
Upload Date: 2007-01-18
Package Size: 51694k
Code Size: 3k
Category:
OS Develop
Development Platform:
WINDOWS
- ." Copyright (c) 1980 Regents of the University of California.
- ." All rights reserved. The Berkeley software License Agreement
- ." specifies the terms and conditions for redistribution.
- ."
- ." @(#)malloc.3 6.3 (Berkeley) 5/14/86
- ."
- .TH MALLOC 3 "May 14, 1986"
- .UC 4
- .SH NAME
- malloc, free, realloc, calloc, alloca - memory allocator
- .SH SYNOPSIS
- .nf
- .ft B
- #include <sys/types.h>
- #include <stdlib.h>
- #include <alloca.h>
- void *malloc(size_t fIsizefP)
- void free(void *fIptrfP)
- void *realloc(void *fIptrfP, size_t fIsizefP)
- void *calloc(size_t fInelemfP, size_t fIelsizefP)
- void *alloca(size_t fIsizefP)
- .ft R
- .fi
- .SH DESCRIPTION
- .B Malloc
- and
- .B free
- provide a general-purpose memory allocation package.
- .B Malloc
- returns a pointer to a block of at least
- .I size
- bytes beginning on a word boundary.
- .PP
- The argument to
- .B free
- is a pointer to a block previously allocated by
- .BR malloc ;
- this space is made available for further allocation,
- but its contents are left undisturbed.
- A call with a null
- .I ptr
- is legal and does nothing.
- .PP
- Needless to say, grave disorder will result if the space assigned by
- .B malloc
- is overrun or if some random number is handed to
- .BR free .
- .PP
- .B Malloc
- maintains multiple lists of free blocks according to size,
- allocating space from the appropriate list.
- It calls
- .B sbrk
- (see
- .BR brk (2))
- to get more memory from the system when there is no
- suitable space already free.
- .PP
- .B Realloc
- changes the size of the block pointed to by
- .I ptr
- to
- .I size
- 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.
- A call with a null
- .I ptr
- is legal and has the same result as
- .BI malloc( size )fR.
- .PP
- .B Calloc
- allocates space for an array of
- .I nelem
- elements of size
- .I elsize.
- The space is initialized to zeros.
- .PP
- .B Alloca
- allocates
- .I size
- bytes of space in the stack frame of the caller.
- This temporary space is automatically freed on
- return.
- .PP
- Each of the allocation routines returns a pointer
- to space suitably aligned (after possible pointer coercion)
- for storage of any type of object.
- .SH SEE ALSO
- .BR brk (2).
- .SH DIAGNOSTICS
- .BR Malloc ,
- .BR realloc
- and
- .B calloc
- return a null pointer if there is no available memory or if the arena
- has been detectably corrupted by storing outside the bounds of a block.
- .SH NOTES
- Other implementations of
- .BR malloc ,
- .BR realloc
- or
- .BR calloc
- may return a null pointer if the size of the requested block is zero. This
- implementation will always return a zero length block at a unique address,
- but you should keep in mind that a null return is possible if the program
- is run to another system and that this should not be mistakenly seen as
- an error.
- .SH BUGS
- When
- .B realloc
- returns a null pointer, the block pointed to by
- .I ptr
- may be destroyed.
- .PP
- .B Alloca
- is machine dependent; its use is discouraged.