Xref: utzoo comp.lang.c:32815 comp.std.c:3750 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!yale!cmcl2!kramden.acf.nyu.edu!brnstnd From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein) Newsgroups: comp.lang.c,comp.std.c Subject: Re: Just a minor new twist on free() Message-ID: <10066:Oct1212:30:5790@kramden.acf.nyu.edu> Date: 12 Oct 90 12:30:57 GMT References: <4d5780ad.20b6d@apollo.HP.COM> Organization: IR Lines: 17 In article <4d5780ad.20b6d@apollo.HP.COM> blodgett@apollo.HP.COM (Bruce Blodgett) writes: > If you are trying to compile code which may call free() with a NULL > argument, and use an implementation of free() that does not handle NULL > gracefully, try adding one of the following to : > #define free(x) ( (x) ? free(x) : ( (void)0 ) ) > #define free(x) { void * ptr = (x); if ( ptr != NULL ) free(ptr); } Much better: #define free(x) ( ( __frx = x ) , ( __frx ? __frol(__frx) : (void) 0 ) ) extern void *__frx; extern void (*__frol)(); In the library source, undef free, define __frx, and define __frol initialized to &free. ---Dan