Path: utzoo!utgpu!watmath!att!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!ginosko!uunet!twwells!bill From: bill@twwells.com (T. William Wells) Newsgroups: comp.lang.c Subject: Re: effect of free() Message-ID: <1989Aug17.005548.745@twwells.com> Date: 17 Aug 89 00:55:48 GMT References: <319@cubmol.BIO.COLUMBIA.EDU> <3756@buengc.BU.EDU><320@cubmol.BIO.COLUMBIA.EDU> <3777@buengc.BU.EDU> Organization: None, Ft. Lauderdale, FL Lines: 22 In article <3777@buengc.BU.EDU> bph@buengc.bu.edu (Blair P. Houghton) writes: : In article <320@cubmol.BIO.COLUMBIA.EDU> ping@cubmol.UUCP (Shiping Zhang) writes: : I guess the word is, once space is freed, don't even try to get data : out of it. It's risky at least, and nonportable without question. Actually, things are worse than that: once the space is freed, don't even *look* at the pointer. For example, the following code fragment is nonportable: char *ptr; ptr = malloc(1); ... free(ptr); ... if (ptr == 0) ... The if might cause a trap when the value of ptr is accessed. --- Bill { uunet | novavax | ankh | sunvice } !twwells!bill bill@twwells.com