Path: utzoo!attcan!uunet!mcsun!unido!mikros!mwtech!martin From: martin@mwtech.UUCP (Martin Weitzel) Newsgroups: comp.lang.c Subject: Re: Just a minor new twist on free() Message-ID: <946@mwtech.UUCP> Date: 26 Oct 90 09:56:20 GMT References: <7365@darkstar.ucsc.edu> <1990Oct02.132313.6659@virtech.uucp> <117@nazgul.UUCP> <280@aud Reply-To: martin@mwtech.UUCP (Martin Weitzel) Organization: MIKROS Systemware, Darmstadt/W-Germany Lines: 18 In article <280@audfax.audiofax.com> arnold@audiofax.com (Arnold Robbins) writes: :In article <117@nazgul.UUCP> bright@nazgul.UUCP (Walter Bright) writes: :>I'd prefer to use, on non-conforming implementations of free(): :> :> #if NONCONFORMINGFREE :> #define free(p) ((p) && free(p)) :> #endif : :Note that this requires an ANSI compliant cpp or C compiler. The original :discussion was about using an ANSI compiler with non-ansi libraries, so that's :fine, but if you try this macro on a pre-ansi cpp it'll recurse forever... And NEVER use this macro with code that contains something like `free(*ptr++)'. The latter construct is not unlikely, if there are arrays of pointers and the space each pointer points to is dynamically allocated ... -- Martin Weitzel, email: martin@mwtech.UUCP, voice: 49-(0)6151-6 56 83