alloca() 'frees' memory when the function returns, not when we exit
authorMonty <xiphmont@xiph.org>
Sat, 18 Dec 1999 18:58:20 +0000 (18:58 +0000)
committerMonty <xiphmont@xiph.org>
Sat, 18 Dec 1999 18:58:20 +0000 (18:58 +0000)
local scope.

Monty

svn path=/trunk/vorbis/; revision=205

vq/train.c

index 29e27ae..7d34b46 100644 (file)
@@ -282,7 +282,7 @@ int main(int argc,char *argv[]){
        }
        {
          int i;
-         double *b=alloca(cols*sizeof(double));
+         double *b=malloc(cols*sizeof(double));
          if(start*num+dim>cols){
            fprintf(stderr,"ran out of columns reading %s\n",file);
            exit(1);
@@ -308,6 +308,7 @@ int main(int argc,char *argv[]){
            vqext_adjdata(b,start+i*dim,dim);
            vqgen_addpoint(&v,b+start+i*dim);
          }
+         free(b);
        }
       }
       fclose(in);