* Create a new connection identifier * \param url database URL * \return connection identifier, or zero on error */
| 310 | * \return connection identifier, or zero on error |
| 311 | */ |
| 312 | struct db_id* new_db_id(const str* url) |
| 313 | { |
| 314 | struct db_id* ptr; |
| 315 | |
| 316 | if (!url || !url->s) { |
| 317 | LM_ERR("invalid parameter\n"); |
| 318 | return 0; |
| 319 | } |
| 320 | |
| 321 | ptr = (struct db_id*)pkg_malloc(sizeof(struct db_id)); |
| 322 | if (!ptr) { |
| 323 | LM_ERR("no private memory left\n"); |
| 324 | goto err; |
| 325 | } |
| 326 | memset(ptr, 0, sizeof(struct db_id)); |
| 327 | |
| 328 | if (parse_db_url(ptr, url) < 0) { |
| 329 | LM_ERR("error while parsing database URL: '%.*s' \n", url->len, url->s); |
| 330 | goto err; |
| 331 | } |
| 332 | |
| 333 | /* store the original url */ |
| 334 | ptr->url.s = url->s; |
| 335 | ptr->url.len = url->len; |
| 336 | |
| 337 | return ptr; |
| 338 | |
| 339 | err: |
| 340 | if (ptr) pkg_free(ptr); |
| 341 | return 0; |
| 342 | } |
| 343 | |
| 344 | |
| 345 | /** |
no test coverage detected