_memmax

return the size of the largest contiguous block of memory available

Synopsis:

#include <malloc.h>
size_t _memmax( void );

Description:

The _memmax() function returns the size of the largest contiguous block 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 need to call _nheapgrow() in these memory models before calling _memmax() in order to get a meaningful result.

Returns:

the size of the largest contiguous block of memory available for dynamic memory allocation in the near heap. If this is 0, then there is no more memory available in the near heap.

See also:

calloc(), _freect(), _memavl(), _heapgrow(), malloc()

Examples:

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

void main()
  {
    char *p;
    size_t size;

    size = _memmax();
    printf( "Maximum memory available is %u\n", size );
    _nheapgrow();
    size = _memmax();
    printf( "Maximum memory available is %u\n", size );
    p = (char *) _nmalloc( size );
    size = _memmax();
    printf( "Maximum memory available is %u\n", size );
  }

produces the output:

Maximum memory available is 0
Maximum memory available is 62700
Maximum memory available is 0

Classification:

WATCOM

Systems:

All (except Netware, DOS/PM)