clones a proxy into pkg memory */
| 328 | |
| 329 | /* clones a proxy into pkg memory */ |
| 330 | struct proxy_l* clone_proxy(struct proxy_l *sp) |
| 331 | { |
| 332 | struct proxy_l *dp; |
| 333 | |
| 334 | dp = (struct proxy_l*)pkg_malloc(sizeof(struct proxy_l)); |
| 335 | if (dp==NULL) { |
| 336 | LM_ERR("no more pkg memory\n"); |
| 337 | return 0; |
| 338 | } |
| 339 | memset( dp , 0 , sizeof(struct proxy_l)); |
| 340 | |
| 341 | dp->port = sp->port; |
| 342 | dp->proto = sp->proto; |
| 343 | dp->addr_idx = sp->addr_idx; |
| 344 | |
| 345 | /* clone the hostent */ |
| 346 | if (hostent_cpy( &dp->host, &sp->host)!=0) |
| 347 | goto error0; |
| 348 | |
| 349 | /* clone the dns resolver */ |
| 350 | if (sp->dn) { |
| 351 | dp->dn = dns_res_copy(sp->dn); |
| 352 | if (dp->dn==NULL) |
| 353 | goto error1; |
| 354 | } |
| 355 | |
| 356 | return dp; |
| 357 | error1: |
| 358 | free_hostent(&dp->host); |
| 359 | error0: |
| 360 | pkg_free(dp); |
| 361 | return 0; |
| 362 | } |
| 363 | |
| 364 |
no test coverage detected