Module: sip-router Branch: janakj/bdb Commit: 423e2078e1fb99c4f5bd2575ba0d739c96d159df URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=423e2078...
Author: Henning Westerholt henning.westerholt@1und1.de Committer: Henning Westerholt henning.westerholt@1und1.de Date: Mon Dec 15 16:33:22 2008 +0000
- unify common rows and row allocation functionality in the DB API core
git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@5362 689a6050-402a-0410-94f2-e92a70836424
---
modules/db_berkeley/bdb_res.c | 31 ++++++------------------------- 1 files changed, 6 insertions(+), 25 deletions(-)
diff --git a/modules/db_berkeley/bdb_res.c b/modules/db_berkeley/bdb_res.c index 93a408b..0049d7b 100644 --- a/modules/db_berkeley/bdb_res.c +++ b/modules/db_berkeley/bdb_res.c @@ -120,20 +120,10 @@ int bdb_convert_row(db_res_t* _res, char *bdb_result, int* _lres) /* Save the number of rows in the current fetch */ RES_ROW_N(_res) = 1;
- /* Allocate storage to hold the bdb result values */ - len = sizeof(db_val_t) * RES_COL_N(_res); - ROW_VALUES(row) = (db_val_t*)pkg_malloc(len); - - if (!ROW_VALUES(row)) { - LM_ERR("no private memory left\n"); - return -1; + if (db_allocate_row(_res, row) != 0) { + LM_ERR("could not allocate row"); + return -2; } - LM_DBG("allocate %d bytes for row values at %p\n", len, ROW_VALUES(row)); - memset(ROW_VALUES(row), 0, len); - - /* Save the number of columns in the ROW structure */ - ROW_N(row) = RES_COL_N(_res); - /* * Allocate an array of pointers one per column. * It that will be used to hold the address of the string representation of each column. @@ -257,19 +247,10 @@ int bdb_append_row(db_res_t* _res, char *bdb_result, int* _lres, int _rx) row = &(RES_ROWS(_res)[_rx]); - /* Allocate storage to hold the bdb result values */ - len = sizeof(db_val_t) * RES_COL_N(_res); - ROW_VALUES(row) = (db_val_t*)pkg_malloc(len); - - if (!ROW_VALUES(row)) { - LM_ERR("no private memory left\n"); - return -1; + if (db_allocate_row(_res, row) != 0) { + LM_ERR("could not allocate row"); + return -2; } - LM_DBG("allocate %d bytes for row values at %p\n", len, ROW_VALUES(row)); - memset(ROW_VALUES(row), 0, len); - - /* Save the number of columns in the ROW structure */ - ROW_N(row) = RES_COL_N(_res); /* * Allocate an array of pointers one per column.