akm*_*mal 2 c argument-passing
而不是用if条件检查每个输入指针参数if( in != NULL ),有更好的方法来做到这一点.一种方法是创建一些宏,比如
#define CHECK_ARG(x) if(!(x)) { return 0; }
Run Code Online (Sandbox Code Playgroud)
在代码中它看起来像这样
int some_func( int * first_arg, int * second_arg )
{
CHECK_ARG( first_arg );
CHECK_ARG( second_arg );
// some operations
//
}
Run Code Online (Sandbox Code Playgroud)
在我看来这是一个很好的方法,但在添加之前,我想知道有没有更好的方法呢?
提前致谢!