Module: sip-router
Branch: janakj/postgres
Commit: abf8e6a4dd9531420b3c0a9dea559377f2ad13b2
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=abf8e6a…
Author: Henning Westerholt <henning.westerholt(a)1und1.de>
Committer: Henning Westerholt <henning.westerholt(a)1und1.de>
Date: Fri Sep 19 11:28:06 2008 +0000
- make small wrapper around PQclear void, nobody checks the return state
- sync db_postgres_free_result function logic with the mysql and unixodbc
modules (check for errors in db_free_result, not necessary set res to 0)
git-svn-id:
https://openser.svn.sourceforge.net/svnroot/openser/trunk@4964
689a6050-402a-0410-94f2-e92a70836424
---
modules/db_postgres/km_dbase.c | 20 +++++++++++---------
1 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/modules/db_postgres/km_dbase.c b/modules/db_postgres/km_dbase.c
index 41a6d51..38bc36f 100644
--- a/modules/db_postgres/km_dbase.c
+++ b/modules/db_postgres/km_dbase.c
@@ -79,7 +79,7 @@
#include "val.h"
#include "res.h"
-static int free_query(const db_con_t* _con);
+static void free_query(const db_con_t* _con);
/*!
@@ -289,9 +289,8 @@ int db_postgres_fetch_result(const db_con_t* _con, db_res_t** _res,
const int nr
/*!
* \brief Free database and any old query results
* \param _h database connection
- * \return 0
*/
-static int free_query(const db_con_t* _con)
+static void free_query(const db_con_t* _con)
{
if(CON_RESULT(_con))
{
@@ -299,8 +298,6 @@ static int free_query(const db_con_t* _con)
PQclear(CON_RESULT(_con));
CON_RESULT(_con) = 0;
}
-
- return 0;
}
@@ -308,14 +305,19 @@ static int free_query(const db_con_t* _con)
* \brief Free the query and the result memory in the core
* \param _con database connection
* \param _r result set
- * \return 0
+ * \return 0 on success, -1 on failure
*/
int db_postgres_free_result(db_con_t* _con, db_res_t* _r)
{
+ if ((!_con) || (!_r)) {
+ LM_ERR("invalid parameter value\n");
+ return -1;
+ }
+ if (db_free_result(_r) < 0) {
+ LM_ERR("unable to free result structure\n");
+ return -1;
+ }
free_query(_con);
- if (_r) db_free_result(_r);
- _r = 0;
-
return 0;
}