Gets the size of the stack available.
#include <malloc.h> | Required only for function declarations |
size_t _stackavail( void );
The _stackavail function returns the approximate size (in bytes) of the stack space available for dynamic memory allocation with _alloca.
The _stackavail function returns the size in bytes as an unsigned integer value.
Standards:None
16-Bit:DOS, QWIN, WIN, WIN DLL
32-Bit:None
/* ALLOCA.C: Checks the stack space available before and after using
* _alloca to allocate space on the stack. As _alloca is incompatible
* with optimizing, compile with optimizations disabled (/Od).
*/
#include <malloc.h>
#include <stdio.h>
void main( void )
{
char *buffer;
printf( "Bytes available on stack: %u\n", _stackavail() );
/* Allocate memory for string. */
buffer = _alloca( 120 * sizeof( char ) );
printf( "Enter a string: " );
gets( buffer );
printf( "You entered: %s\n", buffer );
printf( "Bytes available on stack: %u\n", _stackavail() );
}
Bytes available on stack: 2028
Enter a string: How much stack space will this string take?
You entered: How much stack space will this string take?
Bytes available on stack: 1902