| 25 | int increment = 256 * 1024; |
| 26 | |
| 27 | int main() { |
| 28 | emscripten_stack_init(); |
| 29 | TestStackValidity(); |
| 30 | |
| 31 | uintptr_t origFree = emscripten_stack_get_free(); |
| 32 | uintptr_t prevFree = emscripten_stack_get_free(); |
| 33 | printf("Stack used: %lu\n", origFree - emscripten_stack_get_free()); |
| 34 | for (int i = 0; i < 10; ++i) { |
| 35 | int increment_noopt = emscripten_random() >= 0 ? increment : 2; |
| 36 | char *p = alloca(increment_noopt); |
| 37 | DoSomething(p); |
| 38 | uintptr_t free = emscripten_stack_get_free(); |
| 39 | assert(prevFree - free == increment); |
| 40 | prevFree = free; |
| 41 | // Print something from the allocated region to prevent whole program |
| 42 | // optimizations from eliminating the alloca completely. |
| 43 | printf("Val: %d\n", p[10]); |
| 44 | printf("Stack used: %zu\n", origFree - emscripten_stack_get_free()); |
| 45 | TestStackValidity(); |
| 46 | } |
| 47 | return 0; |
| 48 | } |
nothing calls this directly
no test coverage detected