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

Function db_allocate_rows

db/db_res.c:151–174  ·  view source on GitHub ↗

* Allocate storage for rows in existing * result structure. */

Source from the content-addressed store, hash-verified

149 * result structure.
150 */
151int db_allocate_rows(db_res_t* _res, const unsigned int rows)
152{
153 unsigned int i;
154
155 RES_ROWS(_res) = (struct db_row*)pkg_malloc
156 (rows * (sizeof(db_row_t) + sizeof(db_val_t) * RES_COL_N(_res)) );
157 if (!RES_ROWS(_res)) {
158 LM_ERR("no memory left\n");
159 return -1;
160 }
161 memset( RES_ROWS(_res), 0 ,
162 rows * (sizeof(db_row_t) + sizeof(db_val_t) * RES_COL_N(_res)));
163
164 LM_DBG("allocate %d bytes for result rows and values at %p\n",
165 (int)(rows * (sizeof(db_row_t) + sizeof(db_val_t) * RES_COL_N(_res))),
166 RES_ROWS(_res));
167
168 for( i=0 ; i<rows ; i++ )
169 /* the values of the row i */
170 ROW_VALUES( &(RES_ROWS(_res)[i]) ) =
171 ((db_val_t*)(void *)(RES_ROWS(_res)+rows)) + RES_COL_N(_res)*i;
172
173 return 0;
174}
175
176/*
177 * Extend storage for rows in existing result structure.

Callers 10

db_mysql_convert_rowsFunction · 0.85
db_mysql_fetch_resultFunction · 0.85
get_rowsFunction · 0.85
db_unixodbc_convert_rowsFunction · 0.85
dbt_convert_rowsFunction · 0.85
new_full_db_resFunction · 0.85
perlresult2dbresFunction · 0.85
bdb_queryFunction · 0.85
_bdb_delete_cursorFunction · 0.85
db_postgres_convert_rowsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected