mirror of
https://github.com/PyMySQL/mysqlclient.git
synced 2025-08-15 19:31:54 +08:00
More (de)allocation cleanups, based on suggestions from
python-dev and Skip Montanaro
This commit is contained in:
@ -42,6 +42,11 @@ PERFORMANCE OF THIS SOFTWARE.
|
||||
#include "mysqld_error.h"
|
||||
#include "errmsg.h"
|
||||
|
||||
#if PY_VERSION_HEX < 0x01060000
|
||||
# define PyObject_Del(x) PyMem_Free((char *) x)
|
||||
# define PyObject_New(x,y) PyObject_NEW(x,y)
|
||||
#endif
|
||||
|
||||
static PyObject *_mysql_MySQLError;
|
||||
static PyObject *_mysql_Warning;
|
||||
static PyObject *_mysql_Error;
|
||||
@ -160,11 +165,7 @@ _mysql_ResultObject_New(
|
||||
MYSQL_FIELD *fields;
|
||||
_mysql_ResultObject *r;
|
||||
|
||||
#if PY_VERSION_HEX < 0x02000100
|
||||
r = PyObject_NEW(_mysql_ResultObject, &_mysql_ResultObject_Type);
|
||||
#else
|
||||
r = PyObject_New(_mysql_ResultObject, &_mysql_ResultObject_Type);
|
||||
#endif
|
||||
if (!r) return NULL;
|
||||
r->conn = (PyObject *) conn;
|
||||
r->use = use;
|
||||
@ -240,13 +241,8 @@ _mysql_connect(
|
||||
*read_default_group=NULL;
|
||||
_mysql_ConnectionObject *c=NULL;
|
||||
|
||||
#if PY_VERSION_HEX < 0x02000100
|
||||
c = PyObject_NEW(_mysql_ConnectionObject,
|
||||
&_mysql_ConnectionObject_Type);
|
||||
#else
|
||||
c = PyObject_New(_mysql_ConnectionObject,
|
||||
&_mysql_ConnectionObject_Type);
|
||||
#endif
|
||||
if (c == NULL) return NULL;
|
||||
c->converter = NULL;
|
||||
c->open = 0;
|
||||
@ -1180,11 +1176,7 @@ _mysql_ConnectionObject_dealloc(
|
||||
o = _mysql_ConnectionObject_close(self, NULL);
|
||||
Py_XDECREF(o);
|
||||
}
|
||||
#if PY_VERSION_HEX < 0x02000100
|
||||
PyMem_Free((char *) self);
|
||||
#else
|
||||
PyObject_Del(self);
|
||||
#endif
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
@ -1255,11 +1247,7 @@ _mysql_ResultObject_dealloc(
|
||||
mysql_free_result(self->result);
|
||||
Py_DECREF(self->conn);
|
||||
Py_XDECREF(self->converter);
|
||||
#if PY_VERSION_HEX < 0x02000100
|
||||
PyMem_Free((char *) self);
|
||||
#else
|
||||
PyObject_Del(self);
|
||||
#endif
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
Reference in New Issue
Block a user