File allocate.c:
% ./allocateCode:void f(double **X, int *A, size_t sz) { /* ... */ X = malloc (sz * sizeof(double *)); for (i=0;i<sz;i++) {*X=malloc (A[i]*sizeof (double)); *X++;} } int main () { double **Y = 0; double A[5]={1, 2, 3, 4, 5}; size_t sz = 5; f(Y); }
Segmentation fault
Does f() actually allocate space for Y? I'd like to do it inside of a function, if possible. Any suggestions?