Path: utzoo!attcan!uunet!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.lang.c Subject: Re: Life after free? Keywords: free malloc Message-ID: <464@taumet.com> Date: 27 Sep 90 21:18:43 GMT References: Distribution: comp Organization: Taumetric Corporation, San Diego Lines: 20 quan@sol.surv.utas.oz (Stephen Quan) writes: > char *tmp; > tmp = (char *) malloc(100); > ... > free(tmp); > return tmp; >Any comments on free-ing tmp before it is return-ed? I believe this is in the FAQ, which should always be checked before asking basic questions. You might also RTFM. However: The contents of the malloc'd memory may be changed by free(). In any event, some routine may come along and acquire that space, possibly asynchronously, and overwrite it even if free() doesn't. What problem are you trying to solve by using a pointer to free'd space? -- Steve Clamage, TauMetric Corp, steve@taumet.com