[net.lang.c] free and malloc

joe@emacs.UUCP (Joe Chapman) (10/10/85)

<>

>> Has anyone out there REALLY used "free"?  I'm very curious about this...

Well, I've used free immediately after doing a malloc; the routines in
question needed a considerable amount of space for some nonsensical
operation, and in the convolution which ensued there were several
different places where the function might legitimately return.  Since
free doesn't trash the space, but merely makes it available for re-use,
I wasn't living so perilously as it might appear.

I should probably caution the folks at home against trying this; were I
rewriting that stuff today I'd certainly be a bit more conventional and
less obscure (i.e., put the free at the bottom of the function and goto
it), but I was young then...

--
Joe Chapman	decvax!cca!emacs!joe	joe@cca-unix
	"The dubious practices admitted to herein are no longer
	 even my own, and the fabric of the software with which
	 I and my employer are now associated is devoid of even
	 a suggestion of them."

brooks@lll-crg.ARpA (Eugene D. Brooks III) (10/12/85)

>Does anyone out there really use free?

Yep, I do in packet switched memory server simulators.  I am allocating
and freeing packets all the time.  That is until I realize that I am
spending too much cpu time in malloc and free.  One then only mallocs
10000 of them at a time and links them into a free list which a packet
allocator pmalloc and pfree operate out of. 
.

mikel@codas.UUCP (Mikel Manitius) (10/16/85)

>Does anyone out there really use free?

I used to use it in an old version of a parser I had, it worked
quite well, although I never really got down and benchmarked it.
-- 
	Mikel Manitius - ...{ihnp4|akguc|attmail|indra!koura}!codas!mikel

peter@graffiti.UUCP (Peter da Silva) (10/21/85)

> >Does anyone out there really use free?

YES. Some of us have to write programs that will run to completion in 64K, or
feel that cutting down the size of programs is a good idea. Yes, I free() every
pointer I malloc() as soon as I no longer need it.