memory allocation
Dr. T. Andrews
tanner at cdis-1.uucp
Sat Sep 24 00:01:41 AEST 1988
In article <33692 at XAIT.XEROX.COM>, g-rh at XAIT.XEROX.COM (Richard Harter) writes:
) Immediate coalescence is usually the right thing to do. Your
) strategy for validating freed blocks sounds like it is expensive time
) wise.
Not really. As I scan and coalesce the blocks, I perform the
validation. of the pointers. It's real simple (one "xor"),
but catches most errors. The control block contains only:
[0] back ptr
[1] size of block (is even, the low bit == "in use")
[2] [0] ^ [1]
I don't mind the small expense at free() time, because in general
that's not done nearly as often as malloc() in my applications.
--
...!bikini.cis.ufl.edu!ki4pv!cdis-1!tanner ...!bpa!cdin-1!cdis-1!tanner
or... {allegra killer gatech!uflorida decvax!ucf-cs}!ki4pv!cdis-1!tanner
More information about the Comp.lang.c
mailing list