diff options
| author | James Henstridge <james@jamesh.id.au> | 2008-07-21 13:41:54 +0800 |
|---|---|---|
| committer | James Henstridge <james@jamesh.id.au> | 2008-07-21 13:41:54 +0800 |
| commit | 2273b79be912ab46e58418b077d50d59d5e4511c (patch) | |
| tree | 931b85fc6b7397924ca4defa0ff9e5b432b428f2 /psycopg/adapter_qstring.c | |
| parent | e0287c0db4ceb3daca64b2e3dd32397b357b7e3c (diff) | |
| download | psycopg2-2273b79be912ab46e58418b077d50d59d5e4511c.tar.gz | |
Use Py_CLEAR() in a few more places, and do INCREF's before setting
struct members rather than afterwards.
Diffstat (limited to 'psycopg/adapter_qstring.c')
| -rw-r--r-- | psycopg/adapter_qstring.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/psycopg/adapter_qstring.c b/psycopg/adapter_qstring.c index 32185fe..1fb510b 100644 --- a/psycopg/adapter_qstring.c +++ b/psycopg/adapter_qstring.c @@ -216,10 +216,10 @@ qstring_prepare(qstringObject *self, PyObject *args) Dprintf("qstring_prepare: set encoding to %s", conn->encoding); } - Py_XDECREF(self->conn); + Py_CLEAR(self->conn); if (conn) { + Py_INCREF(conn); self->conn = (PyObject*)conn; - Py_INCREF(self->conn); } Py_INCREF(Py_None); @@ -280,8 +280,8 @@ qstring_setup(qstringObject *self, PyObject *str, const char *enc) /* FIXME: remove this orrible strdup */ if (enc) self->encoding = strdup(enc); + Py_INCREF(str); self->wrapped = str; - Py_INCREF(self->wrapped); Dprintf("qstring_setup: good qstring object at %p, refcnt = " FORMAT_CODE_PY_SSIZE_T, @@ -306,9 +306,9 @@ qstring_dealloc(PyObject* obj) { qstringObject *self = (qstringObject *)obj; - Py_XDECREF(self->wrapped); - Py_XDECREF(self->buffer); - Py_XDECREF(self->conn); + Py_CLEAR(self->wrapped); + Py_CLEAR(self->buffer); + Py_CLEAR(self->conn); if (self->encoding) free(self->encoding); |
