henesyinit from p9f47575dc5 years agoHistory
83 lines · 1.6 KB · Text
RawDownload
.TH MALLOC 2 .SH NAMEmalloc, free, realloc, calloc, mstats \- memory allocator.SH SYNOPSIS.ta \w'\fLvoid* 'u.Bvoid*	malloc(long size).PP.Bvoid	free(void *ptr).PP.Bvoid*	realloc(void *ptr, long size).PP.Bvoid*	calloc(long nelem, long elsize).SH DESCRIPTION.I Mallocand.I freeprovide a simple memory allocation package..I Mallocreturns a pointer to a new block of at least.I sizebytes.The block is suitably aligned for storage of any type of object.No two active pointers from.I mallocwill have the same value..PPThe argument to.I freeis a pointer to a block previously allocated by.IR malloc ;this space is made available for further allocation.It is legal to free a null pointer; the effect is a no-op..PP.I Reallocchanges the size of the block pointed to by.I ptrto.I sizebytes and returns a pointer to the (possibly moved)block.The contents will be unchanged up to thelesser of the new and old sizes.The call.B "realloc(0, size)means the same as.LR malloc(size) ..PP.I Callocallocates space foran array of.I nelemelements of size.I elsize.The space is initialized to zeros..I Freefrees such a block..SH SEE ALSO.IR brk (2).SH DIAGNOSTICS.I Malloc, reallocand.I callocreturn 0 if there is no available memory..I Errstris likely to be set..SH BUGSThe different specification of.I callocis bizarre..PPUser errors can corrupt the storage arena.The most common gaffes are (1) freeing an already freed block,(2) storing beyond the bounds of an allocated block, and (3)freeing data that was not obtained from the allocator.When.I mallocand.I freedetect such corruption, they abort.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t