02.07.2013 Views

A/UX® Programmer's Reference Sections

A/UX® Programmer's Reference Sections

A/UX® Programmer's Reference Sections

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

malloe(3C) malloe(3C)<br />

NAME<br />

malloe, free, realloe, ealloe, efree -- mam<br />

memory allocator<br />

SYNOPSIS<br />

ehar *malloe (size)<br />

unsigned size;<br />

void free (ptr)<br />

ehar *ptr;<br />

ehar *realloe(pw,du)<br />

ehar *ptr;<br />

unsigned size;<br />

ehar *ealloe (nelem, elsize)<br />

unsigned nelem, elsize;<br />

void efree (ptr, nelem, elsize)<br />

ehar *ptr;<br />

unsigned nelem, elsize;<br />

DESCRIPTION<br />

malloe and free provide a simple general-purpose memory allocation<br />

package. malloe returns a pointer to a block of at least<br />

size bytes suitably aligned for any use.<br />

The argument to free is a pointer to a block previously allocated<br />

by malloe; after free is performed, this space is made available<br />

for further allocation, but its contents are left undisturbed.<br />

Undefined results occur if the space assigned by malloe is overrun<br />

or if some random number is handed to free.<br />

malloe allocates the first contiguous reach of free space of<br />

sufficient size found in a circular search from the last block allocated<br />

or freed; it coalesces adjacent free blocks as it searches. It<br />

calls sbrk (see brk(2» to get more memory from the system<br />

when there is no suitable space already free.<br />

realloe changes the size of the block pointed to by ptr to size<br />

bytes and returns a pointer to the (possibly moved) block. The<br />

contents are unchanged up to the lesser of the new and old sizes.<br />

H no free block of size bytes is available m the storage arena,<br />

realloe asks malloe to enlarge the arena by size bytes and<br />

then moves the data to the new space.<br />

February, 1990<br />

RevisionC<br />

1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!