Hi *GCC*:

Given the example for *alloca*() at:

https://www.gnu.org/software/libc/manual/html_mono/libc.html#Alloca-Example

May I recommend that the code below portrays the use of alloca() more
completely in that it demonstrates that it is exiting the containing
function, not the {}
of the first for loop that frees the storage allocated by alloca()?

#include <stdlib.h>
#include <stdio.h>

int main(void)
 {const int N = 26;
  char *(p[N]);
  for(int i = 0; i < N; ++i) {*(p[i] = alloca(1)) = 'a'+i;}
  for(int i = 0; i < N; ++i) putchar(*(p[i]));
  return 0;
 }

// abcdefghijklmnopqrstuvwxyz


-- 
Thanks,

Phil <https://metacpan.org/author/PRBRENAN>

Philip R Brenan <https://metacpan.org/author/PRBRENAN>

Reply via email to