diff options
| author | Carlos Maiolino <[email protected]> | 2025-07-10 22:18:39 +0200 |
|---|---|---|
| committer | Carlos Maiolino <[email protected]> | 2025-07-10 22:18:39 +0200 |
| commit | 8c6fc0c15415b32080a848bbde640e104098cf13 (patch) | |
| tree | 04a21bd28f9dc82c8e216390d6208ed93b9bcd11 /riscv/riscv-probe/examples/alloca/main.c | |
Initial drop
Add some riscv code
Signed-off-by: Carlos Maiolino <[email protected]>
Diffstat (limited to 'riscv/riscv-probe/examples/alloca/main.c')
| -rw-r--r-- | riscv/riscv-probe/examples/alloca/main.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/riscv/riscv-probe/examples/alloca/main.c b/riscv/riscv-probe/examples/alloca/main.c new file mode 100644 index 0000000..af9696a --- /dev/null +++ b/riscv/riscv-probe/examples/alloca/main.c @@ -0,0 +1,17 @@ +#include <stdio.h> +#include <alloca.h> +#include <string.h> + +int main(int argc, char **argv) +{ + const size_t nelems = 4; + const size_t elemsize = 128; + char *alloc[nelems]; + + for (size_t i = 0; i < nelems; i++) { + if (alloc[i] = alloca(elemsize)) { + memset(alloc[i], 0, elemsize); + } + printf("alloca[%d]=0x%x\n", i, alloc[i]); + } +} |
