News for hackers. Stuff that matters.
Re:What is your favourite C programming trick? by ralph on Saturday October 15, 2011 @05:58AM (#3114535)
To avoid the duplication, with risk of mismatch, and to make it one less thing for the reader to check, I have

    #define NEW(a) ((a) = emalloc(sizeof(*(a)))) 
    NEW(foo);
Similarly with NEW0() and ecalloc(). Yes, the macro uses the parameter more than once, and yes it's another macro for the reader to grasp, but it's a simple one and NEW() is used so widely it's soon learnt.

There are no comments on this comment yet.