Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/test/core/test_alloca_stack.c
4150 views
1
/*
2
* Copyright 2016 The Emscripten Authors. All rights reserved.
3
* Emscripten is available under two separate licenses, the MIT license and the
4
* University of Illinois/NCSA Open Source License. Both these licenses can be
5
* found in the LICENSE file.
6
*/
7
8
// We should not blow up the stack with numerous allocas
9
#include <stdio.h>
10
#include <stdlib.h>
11
12
int func(int i) {
13
char *pc = (char *)alloca(100);
14
*pc = i;
15
(*pc)++;
16
return (*pc) % 10;
17
}
18
int main() {
19
int total = 0;
20
for (int i = 0; i < 1024 * 1024; i++) total += func(i);
21
printf("ok:%d*\n", total);
22
return 0;
23
}
24
25