Using macro to check null values

Posted by poliron on Stack Overflow See other posts from Stack Overflow or by poliron
Published on 2012-04-08T19:09:47Z Indexed on 2012/04/08 23:28 UTC
Read the original article Hit count: 131

Filed under:
|
|

My C code contains many functions with pointers to different structs as parameters which shouldn't be NULL pointers. To make my code more readable, I decided to replace this code:

if(arg1==NULL || arg2==NULL || arg3==NULL...) {
    return SOME_ERROR;
}

With that macro:

NULL_CHECK(arg1,arg2,...)

How should I write it, if the number of args is unknown and they can point to different structs?(I work in C99)

© Stack Overflow or respective owner

Related posts about c

    Related posts about code-quality