Just a minor new twist on free()

Dan Bernstein brnstnd at kramden.acf.nyu.edu
Sun Oct 14 08:38:13 AEST 1990


In article <1990Oct12.162928.21807 at watmath.waterloo.edu> rbutterworth at watmath.waterloo.edu (Ray Butterworth) writes:
> In article <10066:Oct1212:30:5790 at kramden.acf.nyu.edu> brnstnd at kramden.acf.nyu.edu (Dan Bernstein) writes:
> >Much better:
> >  #define free(x) ( ( __frx = x ) , ( __frx ? __frol(__frx) : (void) 0 ) )
> >  extern void *__frx;
> >  extern void (*__frol)();
> Which will blow up if an interrupt occurs and changes the value of __frx
> between the assignment and the test, or the test and the __frol call.

So what? The system's free() isn't reentrant either. Now do you see
something incorrect about my implementation, or are you just posting so
you can complain about how difficult it is to use threads in C? If the
latter, try proposing some solutions in alt.lang.cfutures.

---Dan



More information about the Comp.lang.c mailing list