* Create a new connection identifier * \param url database URL * \return connection identifier, or zero on error */
| 397 | * \return connection identifier, or zero on error |
| 398 | */ |
| 399 | struct cachedb_id* new_cachedb_id(const str* url) |
| 400 | { |
| 401 | struct cachedb_id* ptr; |
| 402 | |
| 403 | if (!url || !url->s) { |
| 404 | LM_ERR("invalid parameter\n"); |
| 405 | return 0; |
| 406 | } |
| 407 | |
| 408 | ptr = pkg_malloc(sizeof(struct cachedb_id)); |
| 409 | if (!ptr) { |
| 410 | LM_ERR("no private memory left\n"); |
| 411 | goto err; |
| 412 | } |
| 413 | memset(ptr, 0, sizeof(struct cachedb_id)); |
| 414 | |
| 415 | if (parse_cachedb_url(ptr, url) < 0) { |
| 416 | LM_ERR("error while parsing database URL: '%s'\n", |
| 417 | db_url_escape(url)); |
| 418 | goto err; |
| 419 | } |
| 420 | |
| 421 | return ptr; |
| 422 | |
| 423 | err: |
| 424 | if (ptr) pkg_free(ptr); |
| 425 | return 0; |
| 426 | } |
| 427 | |
| 428 | |
| 429 | /** |