From d36024dc1f68651a598d54940bcab03a189d6fb2 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Sat, 6 Apr 2013 00:42:25 +0100 Subject: [PATCH] Use the Python heap for conn->dsn --- psycopg/connection_type.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/psycopg/connection_type.c b/psycopg/connection_type.c index 89dd635e..9937fdb1 100644 --- a/psycopg/connection_type.c +++ b/psycopg/connection_type.c @@ -1069,10 +1069,7 @@ connection_setup(connectionObject *self, const char *dsn, long int async) self, async, Py_REFCNT(self) ); - if (!(self->dsn = strdup(dsn))) { - PyErr_NoMemory(); - goto exit; - } + if (0 > psycopg_strdup(&self->dsn, dsn, 0)) { goto exit; } if (!(self->notice_list = PyList_New(0))) { goto exit; } if (!(self->notifies = PyList_New(0))) { goto exit; } self->async = async; @@ -1135,7 +1132,7 @@ connection_dealloc(PyObject* obj) conn_notice_clean(self); - if (self->dsn) free(self->dsn); + PyMem_Free(self->dsn); PyMem_Free(self->encoding); PyMem_Free(self->codec); if (self->critical) free(self->critical);