Path: utzoo!yunexus!geac!syntron!jtsv16!uunet!ncrlnk!ncr-sd!hp-sdd!ucsdhub!ucsd!rutgers!att!whuts!homxb!hropus!ki4pv!cdis-1!tanner From: tanner@cdis-1.uucp (Dr. T. Andrews) Newsgroups: comp.lang.c Subject: Re: memory allocation Message-ID: <6913@cdis-1.uucp> Date: 23 Sep 88 14:01:41 GMT Article-I.D.: cdis-1.6913 References: <1262@micomvax.UUCP> <733@proxftl.UUCP> <33184@cca.CCA.COM> <33692@XAIT.XEROX.COM> Distribution: comp.lang.c,comp.os.misc Organization: CompuData Inc, DeLand Lines: 17 In article <33692@XAIT.XEROX.COM>, g-rh@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