effect of free()

Bruce Evans evans at ditsyda.oz
Sun Sep 10 06:13:51 AEST 1989


In article <10982 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn) writes:
>In article <247 at ssp1.idca.tds.philips.nl> dolf at idca.tds.PHILIPS.nl (Dolf Grunbauer) writes:
>>What about the case when ptr is already in a register
>>(i.e. definition of ptr: register char *ptr) ? Will there be an address trap
>>right after the free as some address register now holds an invalid address ?
>
>No, provided that you don't try to copy the now-defunct address into some
>other variable or to use it in any other way.  Storing a valid address in

	register char *ptr;
	...
	free(ptr);

The compiler will have difficulty maintaining the register across the function
call. It might have to forbid pointers in registers, or they might not fit.
A loss either way.
-- 
Bruce Evans		evans at ditsyda.oz.au



More information about the Comp.lang.c mailing list