git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@5362 689a6050-402a-0410-94f2-e92a70836424
... | ... |
@@ -157,7 +157,7 @@ int db_mysql_get_columns(const db_con_t* _h, db_res_t* _r) |
157 | 157 |
*/ |
158 | 158 |
static inline int db_mysql_convert_rows(const db_con_t* _h, db_res_t* _r) |
159 | 159 |
{ |
160 |
- int row, len; |
|
160 |
+ int row; |
|
161 | 161 |
|
162 | 162 |
if ((!_h) || (!_r)) { |
163 | 163 |
LM_ERR("invalid parameter\n"); |
... | ... |
@@ -171,14 +171,10 @@ static inline int db_mysql_convert_rows(const db_con_t* _h, db_res_t* _r) |
171 | 171 |
return 0; |
172 | 172 |
} |
173 | 173 |
|
174 |
- len = sizeof(db_row_t) * RES_ROW_N(_r); |
|
175 |
- RES_ROWS(_r) = (struct db_row*)pkg_malloc(len); |
|
176 |
- if (!RES_ROWS(_r)) { |
|
177 |
- LM_ERR("no private memory left\n"); |
|
174 |
+ if (db_allocate_rows(_r) < 0) { |
|
175 |
+ LM_ERR("could not allocate rows"); |
|
178 | 176 |
return -2; |
179 | 177 |
} |
180 |
- LM_DBG("allocate %d bytes for rows at %p\n", len, RES_ROWS(_r)); |
|
181 |
- memset(RES_ROWS(_r), 0, len); |
|
182 | 178 |
|
183 | 179 |
for(row = 0; row < RES_ROW_N(_r); row++) { |
184 | 180 |
CON_ROW(_h) = mysql_fetch_row(CON_RESULT(_h)); |
... | ... |
@@ -47,26 +47,18 @@ |
47 | 47 |
int db_mysql_convert_row(const db_con_t* _h, db_res_t* _res, db_row_t* _r) |
48 | 48 |
{ |
49 | 49 |
unsigned long* lengths; |
50 |
- int i, len; |
|
50 |
+ int i; |
|
51 | 51 |
|
52 | 52 |
if ((!_h) || (!_res) || (!_r)) { |
53 | 53 |
LM_ERR("invalid parameter value\n"); |
54 | 54 |
return -1; |
55 | 55 |
} |
56 | 56 |
|
57 |
- len = sizeof(db_val_t) * RES_COL_N(_res); |
|
58 |
- ROW_VALUES(_r) = (db_val_t*)pkg_malloc(len); |
|
59 |
- if (!ROW_VALUES(_r)) { |
|
60 |
- LM_ERR("no private memory left\n"); |
|
61 |
- return -1; |
|
57 |
+ if (db_allocate_row(_res, _r) != 0) { |
|
58 |
+ LM_ERR("could not allocate row"); |
|
59 |
+ return -2; |
|
62 | 60 |
} |
63 |
- LM_DBG("allocate %d bytes for row values at %p\n", len, |
|
64 |
- ROW_VALUES(_r)); |
|
65 |
- |
|
66 |
- memset(ROW_VALUES(_r), 0, len); |
|
67 |
- /* Save the number of columns in the ROW structure */ |
|
68 |
- ROW_N(_r) = RES_COL_N(_res); |
|
69 |
- |
|
61 |
+ |
|
70 | 62 |
lengths = mysql_fetch_lengths(CON_RESULT(_h)); |
71 | 63 |
|
72 | 64 |
for(i = 0; i < RES_COL_N(_res); i++) { |