shrink a heap to its smallest possible size
#include <malloc.h> int _heapshrink( void ); int _bheapshrink( __segment seg ); int _fheapshrink( void ); int _nheapshrink( void );
The _heapshrink() functions attempt to shrink the heap to its smallest possible size by returning all free entries at the end of the heap back to the system. This can be used to free up as much memory as possible before using the system() function or one of the spawn() functions.
The various _heapshrink() functions shrink the following heaps:
In a small data memory model, the _heapshrink() function is equivalent to the _nheapshrink() function; in a large data memory model, the _heapshrink() function is equivalent to the _fheapshrink() function. It is identical to the _heapmin() function.
These functions return zero if successful, and non-zero if some error occurred.
_heapchk(), _heapenable(), _heapgrow(), _heapmin(), _heapset(), _heapwalk()
#include <stdlib.h> #include <malloc.h> void main() { _heapshrink(); system( "cd /home/fred" ); }
WATCOM