Hello.
I requesting memory from the stack using the function alloca.
I know that the use of it is discourage, but I want use it anyways.
I write a code for windows that use it and I tested ok, but only when I compile with gcc. Compiling it with tiny c fails, the program crash.
Maybe is a bug of tiny c.
This is the code:
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <malloc.h>
#include <setjmp.h>
int _resetstkoflw ( void );
static jmp_buf alloca_jmp_buf;
LONG WINAPI AllocaExceptionFilter(EXCEPTION_POINTERS *ExceptionInfo)
{
switch(ExceptionInfo->ExceptionRecord->ExceptionCode) {
case STATUS_STACK_OVERFLOW :
// reset the stack
if (0 == _resetstkoflw()) {
printf("Could not reset the stack!\n");
_exit(1);
}
longjmp(alloca_jmp_buf, 1);
break;
}
return EXCEPTION_EXECUTE_HANDLER;
}
//Alloca survive. Programmed by Carlos Montiers.