Just a minor new twist on free()
Martin Weitzel
martin at mwtech.UUCP
Fri Oct 26 19:56:20 AEST 1990
In article <280 at audfax.audiofax.com> arnold at audiofax.com (Arnold Robbins) writes:
:In article <117 at nazgul.UUCP> bright at 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 at mwtech.UUCP, voice: 49-(0)6151-6 56 83
More information about the Comp.lang.c
mailing list