Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C Library Reference - these functions allocate and de-allocate blocks of memory. http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
These functions allocate and de-allocate blocks of memory.

Unless you are running your program in 32-bit protect mode, where segments
have a limit of 4 gigabytes, the default data segment has a maximum size of
64K bytes.  It may be less in a machine with insufficient memory or when
other programs in the computer already occupy some of the memory.  The
 _nmalloc function allocates space within this area while the  _fmalloc
function allocates space outside the area (if it is available).

In a small data model, the  malloc,  calloc and  realloc functions use the
 _nmalloc function to acquire memory; in a large data model, the  _fmalloc
function is used.

It is also possible to allocate memory from a based heap using  _bmalloc.
 Based heaps are similar to far heaps in that they are located outside the
normal data segment.  Based pointers only store the offset portion of the
full address, so they behave much like near pointers.  The selector portion
of the full address specifies which based heap a based pointer belongs to,
and must be passed to the various based heap functions.

It is important to use the appropriate memory-deallocation function to free
memory blocks.  The  _nfree function should be used to free space acquired
by the  _ncalloc,  _nmalloc, or  _nrealloc functions.  The  _ffree function
should be used to free space acquired by the  _fcalloc,  _fmalloc, or
 _frealloc functions.  The  _bfree function should be used to free space
acquired by the  _bcalloc,  _bmalloc, or  _brealloc functions.

The  free function will use the  _nfree function when the small data memory
model is used; it will use the  _ffree function when the large data memory
model is being used.

It should be noted that the  _fmalloc and  _nmalloc functions can both be
used in either data memory model.  The following functions are defined:

alloca
    allocate auto storage from stack

_bcalloc (see calloc)
    allocate and zero memory from a based heap

_bexpand (see _expand)
    expand a block of memory in a based heap

_bfree (see free)
    free a block of memory in a based heap

_bfreeseg
    free a based heap

_bheapseg
    allocate a based heap

_bmalloc (see malloc)
    allocate a memory block from a based heap

_bmsize (see _msize)
    return the size of a memory block

_brealloc (see realloc)
    re-allocate a memory block in a based heap

calloc
    allocate and zero memory

_expand
    expand a block of memory

_fcalloc (see calloc)
    allocate and zero a memory block (outside default data segment)

_fexpand (see _expand)
    expand a block of memory (outside default data segment)

_ffree (see free)
    free a block allocated using "_fmalloc"

_fmalloc (see malloc)
    allocate a memory block (outside default data segment)

_fmsize (see _msize)
    return the size of a memory block

_frealloc (see realloc)
    re-allocate a memory block (outside default data segment)

free
    free a block allocated using "malloc", "calloc" or "realloc"

_freect
    return number of objects that can be allocated

halloc
    allocate huge array

hfree
    free huge array

malloc
    allocate a memory block (using current memory model)

_memavl
    return amount of available memory

_memmax
    return largest block of memory available

_msize
    return the size of a memory block

_ncalloc (see calloc)
    allocate and zero a memory block (inside default data segment)

_nexpand (see _expand)
    expand a block of memory (inside default data segment)

_nfree (see free)
    free a block allocated using "_nmalloc"

_nmalloc (see malloc)
    allocate a memory block (inside default data segment)

_nmsize (see _msize)
    return the size of a memory block

_nrealloc (see realloc)
    re-allocate a memory block (inside default data segment)

realloc
    re-allocate a block of memory

sbrk
    set allocation "break" position

stackavail
    determine available amount of stack space

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson