Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!hsdndev!cmcl2!kramden.acf.nyu.edu!brnstnd From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein) Newsgroups: comp.lang.c Subject: Re: memory management between functions Message-ID: <6394:Apr2915:34:0991@kramden.acf.nyu.edu> Date: 29 Apr 91 15:34:09 GMT References: <8504@umd5.umd.edu> Distribution: na Organization: IR Lines: 12 In article <8504@umd5.umd.edu> jjk@astro.umde.edu (Jim Klavetter) writes: > for(i=0; i c[i]=a[i]-b[i]; > free(c); > return(c); A pointer is just an address. The pointer variable c holds the address of a malloc'ed array. When you blow away the array, c's address is out of date, and once the array elements are dead and buried the postmaster can't forward your mail (c[i]) to the cemetery. ---Dan