MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / dbt_convert_rows

Function dbt_convert_rows

modules/db_text/dbt_api.c:191–229  ·  view source on GitHub ↗

* Convert rows from internal to db API representation */

Source from the content-addressed store, hash-verified

189 * Convert rows from internal to db API representation
190 */
191static int dbt_convert_rows(db_con_t* _h, db_res_t* _r)
192{
193 int col;
194 dbt_row_p _rp = NULL;
195 if (!_h || !_r) {
196 LM_ERR("invalid parameter\n");
197 return -1;
198 }
199 RES_ROW_N(_r) = DBT_CON_RESULT(_h)->nrrows;
200 if (!RES_ROW_N(_r)) {
201 return 0;
202 }
203
204 if (db_allocate_rows( _r, RES_ROW_N(_r))!=0) {
205 LM_ERR("no private memory left\n");
206 return -2;
207 }
208
209 col = 0;
210 _rp = DBT_CON_RESULT(_h)->rows;
211 while(_rp) {
212 DBT_CON_ROW(_h) = _rp;
213 if (!DBT_CON_ROW(_h)) {
214 LM_ERR("failed to get current row\n");
215 RES_ROW_N(_r) = col;
216 db_free_rows(_r);
217 return -3;
218 }
219 if (dbt_convert_row(_h, _r, &(RES_ROWS(_r)[col])) < 0) {
220 LM_ERR("failed to convert row #%d\n", col);
221 RES_ROW_N(_r) = col;
222 db_free_rows(_r);
223 return -4;
224 }
225 col++;
226 _rp = _rp->next;
227 }
228 return 0;
229}
230
231
232/*

Callers 1

dbt_convert_resultFunction · 0.85

Calls 3

db_allocate_rowsFunction · 0.85
db_free_rowsFunction · 0.85
dbt_convert_rowFunction · 0.85

Tested by

no test coverage detected