* Duplicate linked list of parameters */
| 527 | * Duplicate linked list of parameters |
| 528 | */ |
| 529 | static inline int do_duplicate_params(param_t** _n, param_t* _p, int _shm) |
| 530 | { |
| 531 | param_t* last, *ptr, *t; |
| 532 | |
| 533 | if (!_n) { |
| 534 | LM_ERR("invalid parameter value\n"); |
| 535 | return -1; |
| 536 | } |
| 537 | |
| 538 | last = 0; |
| 539 | *_n = 0; |
| 540 | ptr = _p; |
| 541 | while(ptr) { |
| 542 | if (_shm) { |
| 543 | t = (param_t*)shm_malloc(sizeof(param_t)); |
| 544 | } else { |
| 545 | t = (param_t*)pkg_malloc(sizeof(param_t)); |
| 546 | } |
| 547 | if (!t) { |
| 548 | LM_ERR("no more pkg memory\n"); |
| 549 | goto err; |
| 550 | } |
| 551 | memcpy(t, ptr, sizeof(param_t)); |
| 552 | t->next = 0; |
| 553 | |
| 554 | if (!*_n) *_n = t; |
| 555 | if (last) last->next = t; |
| 556 | last = t; |
| 557 | |
| 558 | ptr = ptr->next; |
| 559 | } |
| 560 | return 0; |
| 561 | |
| 562 | err: |
| 563 | do_free_params(*_n, _shm); |
| 564 | return -2; |
| 565 | } |
| 566 | |
| 567 | |
| 568 | /* |
no test coverage detected