Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ 3.0r4 - <b>_chkstack</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
_chkstack

Usage

   #include <dos.h>
   size_t _chkstack(void);

Description

   _chkstack determines if the stack has grown larger than the memory
   allocated for it and if so, aborts the program with a stack overflow
   message. This function should be called in recursive functions or other
   functions that might use a lot of stack space. Alternatively, stack
   checking can be inserted in the code automatically at compilation both
   from within the environment and by using the -s switch in the ZTC command
   line.

   In the X and P memory models, the 80386 segment protection mechanism
   automatically aborts the program if stack space grows into the heap so
   this function is not implemented.

Example 

   #include <dos.h>

   /* do_tree is a recursive func */

   do_tree(struct tree *t)

   {
   #ifdef __ZTC__      /* defined if Zortech C / C++ */
       _chkstack();
   #endif

       /* ...more code...  */

       do_tree(t->left);
       do_tree(t->right);
   }

Return Value

   Returns the number of bytes left on the stack, if the stack has not
   overflowed.





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