[SR-Dev] git:janakj/bdb: - move new_result and free_columns function to db directory

Jan Janak jan at iptel.org
Thu Feb 19 15:05:57 CET 2009


Module: sip-router
Branch: janakj/bdb
Commit: bf8025342869781330da349b61dafad996bff09c
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=bf8025342869781330da349b61dafad996bff09c

Author: Henning Westerholt <henning.westerholt at 1und1.de>
Committer: Henning Westerholt <henning.westerholt at 1und1.de>
Date:   Fri Oct  5 14:32:16 2007 +0000

- move new_result and free_columns function to db directory
- remove the implementation of this functions in all database modules
- still missing
  - postgresql and db_berkeley implement different, more thouroughly
    free methods for colums and such
  - review if we can use the common functions like the other three modules


git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@2871 689a6050-402a-0410-94f2-e92a70836424

---

 modules/db_berkeley/km_bdb_res.c     |   16 ----------------
 modules/db_berkeley/km_bdb_res.h     |    1 -
 modules/db_berkeley/km_db_berkeley.c |    7 ++++---
 3 files changed, 4 insertions(+), 20 deletions(-)

diff --git a/modules/db_berkeley/km_bdb_res.c b/modules/db_berkeley/km_bdb_res.c
index a8a1a63..a6823ac 100644
--- a/modules/db_berkeley/km_bdb_res.c
+++ b/modules/db_berkeley/km_bdb_res.c
@@ -499,22 +499,6 @@ int* sc_get_colmap(table_p _dtp, db_key_t* _k, int _n)
 }
 
 
-db_res_t* sc_result_new(void)
-{
-	db_res_t* _res = NULL;
-	_res = (db_res_t*)pkg_malloc(sizeof(db_res_t));
-	if (!_res) 
-	{
-		LM_ERR("Failed to allocate %lu bytes for result structure\n"
-			, (unsigned long)sizeof(db_res_t));
-		return NULL;
-	}
-	
-	memset(_res, 0, sizeof(db_res_t));
-	return _res;
-}
-
-
 int sc_free_result(db_res_t* _res)
 {
 	sc_free_columns(_res);
diff --git a/modules/db_berkeley/km_bdb_res.h b/modules/db_berkeley/km_bdb_res.h
index 79685fd..77fded0 100644
--- a/modules/db_berkeley/km_bdb_res.h
+++ b/modules/db_berkeley/km_bdb_res.h
@@ -53,7 +53,6 @@ int sc_convert_row( db_res_t* _res, char *bdb_result, int* _lres);
 int sc_append_row(db_res_t* _res, char *bdb_result, int* _lres, int _rx);
 int* sc_get_colmap(table_p _tp, db_key_t* _k, int _n);
 
-db_res_t*  sc_result_new(void);
 int sc_free_result(db_res_t* _res);
 int sc_free_columns(db_res_t* _res);
 int sc_free_rows(db_res_t* _res);
diff --git a/modules/db_berkeley/km_db_berkeley.c b/modules/db_berkeley/km_db_berkeley.c
index 08fc907..af464a4 100644
--- a/modules/db_berkeley/km_db_berkeley.c
+++ b/modules/db_berkeley/km_db_berkeley.c
@@ -36,6 +36,7 @@
 #include "../../mem/mem.h"
 
 #include "../../sr_module.h"
+#include "../../db/db_res.h"
 #include "db_berkeley.h"
 #include "bdb_lib.h"
 #include "bdb_res.h"
@@ -428,7 +429,7 @@ int sc_query(db_con_t* _con, db_key_t* _k, db_op_t* _op, db_val_t* _v,
 		LM_DBG("%i = SELECT COUNT(*) FROM %.*s\n", i, _tp->name.len, _tp->name.s);
 #endif
 
-		*_r = sc_result_new();
+		*_r = db_new_result();
 		if (!*_r) 
 		{	LM_ERR("no memory left for result \n");
 			ret = -2;
@@ -504,7 +505,7 @@ int sc_query(db_con_t* _con, db_key_t* _k, db_op_t* _op, db_val_t* _v,
 	data.flags = DB_DBT_USERMEM;
 
 	/*create an empty db_res_t which gets returned even if no result*/
-	*_r = sc_result_new();
+	*_r = db_new_result();
 	if (!*_r) 
 	{	LM_ERR("no memory left for result \n");
 		ret = -2;
@@ -926,7 +927,7 @@ int _sc_delete_cursor(db_con_t* _h, db_key_t* _k, db_op_t* _op, db_val_t* _v, in
 	}
 	
 	/* create an empty db_res_t which gets returned even if no result */
-	_r = sc_result_new();
+	_r = db_new_result();
 	if (!_r) 
 	{	LM_ERR("no memory for result \n");
 	}




More information about the sr-dev mailing list