bcannon> Defined macros Py_RETURN_(TRUE|FALSE|NONE) as helper functions bcannon> for returning the specified value. All three Py_INCREF the bcannon> singleton and then return it. ... bcannon> + /* Macro for returning Py_None from a function */ bcannon> + #define Py_RETURN_NONE Py_INCREF(Py_None); return Py_None; ... bcannon> + /* Macros for returning Py_True or Py_False, respectively */ bcannon> + #define Py_RETURN_TRUE Py_INCREF(Py_True); return Py_True; bcannon> + #define Py_RETURN_FALSE Py_INCREF(Py_False); return Py_False; These don't look right to me. First, you have no protection against them being called like this: if (!error) Py_RETURN_TRUE; Second, any time you expect to use a macro in a statement context, I don't think you want to terminate it with a semicolon (the programmer will do that). I would have coded them as #define Py_RETURN_NONE do {Py_INCREF(Py_None); return Py_None;} while (0) #define Py_RETURN_TRUE do {Py_INCREF(Py_True); return Py_True;} while (0) #define Py_RETURN_FALSE do {Py_INCREF(Py_False); return Py_False;} while (0) Skip
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4