All pastes #911941 Raw Edit

VLA

public c v1 · immutable
·published 2008-02-21 00:48 UTC
rendered paste body
#include <stdio.h>#include <stdlib.h>#include <alloca.h>void foo_alloca(size_t s);void foo_vla(size_t s);intmain(int argc, char* argv[]){    size_t s = 1024 * 1024 * 1024;    foo_vla(s);    foo_alloca(s);    return 0;}voidfoo_alloca(size_t s){    size_t j;    int* i = (int *) alloca(s);    for (j = 0; j < s; j++)        i[j] = j;}voidfoo_vla(size_t s){    size_t j;    int i[s];    for (j = 0; j < s; j++)        i[j] = j;}