Date: Sun, 2 Apr 1995 22:48:58 -0400 From: dj (DJ Delorie) To: mat AT ardi DOT com Cc: djgpp AT sun DOT soe DOT clarkson DOT edu Subject: Re: Dynamic allocation question > Some programmers also install magic sentinel values before and after > the requested block of memory, which can get checked at various times > (e.g. all calls to my_free and my_realloc) for memory smashage. At Cabletron, we do exactly that, at both byte and word granularity. Also add header checksums and user-provided info, stack tracebacks, and other information into each malloc'd chunk, and check it on free (optionally, check everything on every free - ouch). *Very* helpful in debugging memory problems, but put a lot of overhead on the program. Our motto was, "If you can't solve the problem in three hours, let CsMalloc solve it for you". It took that long in full debug mode -- really -- but it always found the problem. The best developer's hint I saw concerning malloc() was to implment "new" and "delete" as: new(x) return malloc(x+N)+N; delete(x) free(x-N); With a suitable debugging malloc, you can't mix new/delete with malloc/free and get away with it. Great for pedants. DJ