mirror of
https://github.com/python/cpython
synced 2024-10-14 11:53:54 +00:00
Use NULL rather than 0. (#778)
There was few cases of using literal 0 instead of NULL in the context of pointers. While this was a legitimate C code, using NULL rather than 0 makes the code clearer.
This commit is contained in:
parent
aefa7ebf0f
commit
0b3ec19225
|
@ -365,14 +365,14 @@ dialect_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
||||||
Py_INCREF(dialect);
|
Py_INCREF(dialect);
|
||||||
/* Can we reuse this instance? */
|
/* Can we reuse this instance? */
|
||||||
if (PyObject_TypeCheck(dialect, &Dialect_Type) &&
|
if (PyObject_TypeCheck(dialect, &Dialect_Type) &&
|
||||||
delimiter == 0 &&
|
delimiter == NULL &&
|
||||||
doublequote == 0 &&
|
doublequote == NULL &&
|
||||||
escapechar == 0 &&
|
escapechar == NULL &&
|
||||||
lineterminator == 0 &&
|
lineterminator == NULL &&
|
||||||
quotechar == 0 &&
|
quotechar == NULL &&
|
||||||
quoting == 0 &&
|
quoting == NULL &&
|
||||||
skipinitialspace == 0 &&
|
skipinitialspace == NULL &&
|
||||||
strict == 0)
|
strict == NULL)
|
||||||
return dialect;
|
return dialect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,7 @@ _ctypes_get_errobj(int **pspace)
|
||||||
PyObject *dict = PyThreadState_GetDict();
|
PyObject *dict = PyThreadState_GetDict();
|
||||||
PyObject *errobj;
|
PyObject *errobj;
|
||||||
static PyObject *error_object_name;
|
static PyObject *error_object_name;
|
||||||
if (dict == 0) {
|
if (dict == NULL) {
|
||||||
PyErr_SetString(PyExc_RuntimeError,
|
PyErr_SetString(PyExc_RuntimeError,
|
||||||
"cannot get thread state");
|
"cannot get thread state");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -2987,7 +2987,7 @@ PyCurses_tigetstr(PyObject *self, PyObject *args)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
capname = tigetstr( capname );
|
capname = tigetstr( capname );
|
||||||
if (capname == 0 || capname == (char*) -1) {
|
if (capname == NULL || capname == (char*) -1) {
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
return PyBytes_FromString( capname );
|
return PyBytes_FromString( capname );
|
||||||
|
|
|
@ -643,7 +643,7 @@ static void _pysqlite_step_callback(sqlite3_context *context, int argc, sqlite3_
|
||||||
|
|
||||||
aggregate_instance = (PyObject**)sqlite3_aggregate_context(context, sizeof(PyObject*));
|
aggregate_instance = (PyObject**)sqlite3_aggregate_context(context, sizeof(PyObject*));
|
||||||
|
|
||||||
if (*aggregate_instance == 0) {
|
if (*aggregate_instance == NULL) {
|
||||||
*aggregate_instance = _PyObject_CallNoArg(aggregate_class);
|
*aggregate_instance = _PyObject_CallNoArg(aggregate_class);
|
||||||
|
|
||||||
if (PyErr_Occurred()) {
|
if (PyErr_Occurred()) {
|
||||||
|
|
|
@ -434,7 +434,7 @@ PyMODINIT_FUNC PyInit__sqlite3(void)
|
||||||
PyDict_SetItemString(dict, "OptimizedUnicode", (PyObject*)&PyUnicode_Type);
|
PyDict_SetItemString(dict, "OptimizedUnicode", (PyObject*)&PyUnicode_Type);
|
||||||
|
|
||||||
/* Set integer constants */
|
/* Set integer constants */
|
||||||
for (i = 0; _int_constants[i].constant_name != 0; i++) {
|
for (i = 0; _int_constants[i].constant_name != NULL; i++) {
|
||||||
tmp_obj = PyLong_FromLong(_int_constants[i].constant_value);
|
tmp_obj = PyLong_FromLong(_int_constants[i].constant_value);
|
||||||
if (!tmp_obj) {
|
if (!tmp_obj) {
|
||||||
goto error;
|
goto error;
|
||||||
|
|
|
@ -1378,7 +1378,7 @@ Tkapp_CallArgs(PyObject *args, Tcl_Obj** objStore, int *pobjc)
|
||||||
|
|
||||||
else if (!(PyTuple_Check(args) || PyList_Check(args))) {
|
else if (!(PyTuple_Check(args) || PyList_Check(args))) {
|
||||||
objv[0] = AsObj(args);
|
objv[0] = AsObj(args);
|
||||||
if (objv[0] == 0)
|
if (objv[0] == NULL)
|
||||||
goto finally;
|
goto finally;
|
||||||
objc = 1;
|
objc = 1;
|
||||||
Tcl_IncrRefCount(objv[0]);
|
Tcl_IncrRefCount(objv[0]);
|
||||||
|
|
|
@ -2179,7 +2179,7 @@ BOOL MyIsUserAnAdmin()
|
||||||
// to leave the library loaded)
|
// to leave the library loaded)
|
||||||
if (0 == (shell32=LoadLibrary("shell32.dll")))
|
if (0 == (shell32=LoadLibrary("shell32.dll")))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (0 == (pfnIsUserAnAdmin=(PFNIsUserAnAdmin)GetProcAddress(shell32, "IsUserAnAdmin")))
|
if (NULL == (pfnIsUserAnAdmin=(PFNIsUserAnAdmin)GetProcAddress(shell32, "IsUserAnAdmin")))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
return (*pfnIsUserAnAdmin)();
|
return (*pfnIsUserAnAdmin)();
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ listnode(FILE *fp, node *n)
|
||||||
static void
|
static void
|
||||||
list1node(FILE *fp, node *n)
|
list1node(FILE *fp, node *n)
|
||||||
{
|
{
|
||||||
if (n == 0)
|
if (n == NULL)
|
||||||
return;
|
return;
|
||||||
if (ISNONTERMINAL(TYPE(n))) {
|
if (ISNONTERMINAL(TYPE(n))) {
|
||||||
int i;
|
int i;
|
||||||
|
|
Loading…
Reference in a new issue