2 ms·
The code to do what you describe is going to be nicer with alloca, because of the similarity between alloca and malloc. type *ptr = (nelem > THRESH)
by kazinator 10y ago
The code to do what you describe is going to be nicer with alloca, because of the similarity between alloca and malloc.
type *ptr = (nelem > THRESH)
? malloc(nelem * sizeof *ptr)
: alloca(nelem * sizeof *ptr);
/*...*/
if (nelem > THRESH)
free(ptr);