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>
    unsigned int _freect( size_t size );

Description:
    The _freect function returns the number of times that  _nmalloc (or
     malloc in small data models) can be called to allocate a item of size
    bytes.  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 _freect in order to get a meaningful
    result.

Returns:
    The _freect function returns the number of calls as an unsigned integer.

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

    void main()
      {
        int  i;

        printf( "Can allocate %u longs before _nheapgrow\n",
                _freect( sizeof(long) ) );
        _nheapgrow();
        printf( "Can allocate %u longs after _nheapgrow\n",
                _freect( sizeof(long) ) );
        for( i = 1; i < 1000; i++ ) {
          _nmalloc( sizeof(long) );
        }
        printf( "After allocating 1000 longs:\n" );
        printf( "Can still allocate %u longs\n",
                _freect( sizeof(long) ) );
      }

    produces the following:

    Can allocate 0 longs before _nheapgrow
    Can allocate 10447 longs after _nheapgrow
    After allocating 1000 longs:
    Can still allocate 9447 longs

Classification:
    WATCOM

Systems:
    All

See Also:
    calloc, _heapgrow Functions, malloc Functions, _memavl, _memmax

See Also: _memavl _memmax

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