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 - <u>synopsis:</u> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <malloc.h>
    size_t _memavl( void );

Description:
    The _memavl function returns the number of bytes of memory available for
    dynamic memory allocation in the near heap (the default data segment).
     In the tiny, small and medium memory models, the default data segment
    is only extended as needed to satisfy requests for memory allocation.
     Therefore, you will need to call  _nheapgrow in these memory models
    before calling _memavl in order to get a meaningful result.

    The number returned by _memavl may not represent a single contiguous
    block of memory.  Use the  _memmax function to find the largest
    contiguous block of memory that can be allocated.

Returns:
    The _memavl function returns the number of bytes of memory available for
    dynamic memory allocation in the near heap (the default data segment).

Example:
    #include <stdio.h>
    #include <malloc.h>

    void main()
      {
        char *p;
        char *fmt = "Memory available = %u\n";

        printf( fmt, _memavl() );
        _nheapgrow();
        printf( fmt, _memavl() );
        p = (char *) malloc( 2000 );
        printf( fmt, _memavl() );
      }

    produces the following:

    Memory available = 0
    Memory available = 62732
    Memory available = 60730

Classification:
    WATCOM

Systems:
    All

See Also:
    calloc Functions, _freect, _memmax, _heapgrow Functions, malloc
    Functions, realloc Functions

See Also: _freect _memmax

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