! \brief * Removes a msg branch by index. The whole array gets shifted, so the * indexes inside may change */
| 457 | * indexes inside may change |
| 458 | */ |
| 459 | int remove_msg_branch(unsigned int idx) |
| 460 | { |
| 461 | struct dset_ctx *dsct = get_dset_ctx(); |
| 462 | int i; |
| 463 | |
| 464 | if (!dsct || !dsct->enabled || idx >= dsct->nr_branches) |
| 465 | return -1; |
| 466 | |
| 467 | /* destroy any attrs the branch may have */ |
| 468 | destroy_avp_list( &dsct->branches[idx].branch.attrs ); |
| 469 | |
| 470 | /* not last branch? */ |
| 471 | if (idx + 1 != dsct->nr_branches) { |
| 472 | memmove( dsct->branches + idx, dsct->branches + idx + 1, |
| 473 | (dsct->nr_branches - idx - 1) * sizeof *dsct->branches); |
| 474 | /* update internal links */ |
| 475 | for ( i=idx ; i<dsct->nr_branches-1 ; i++) |
| 476 | _post_copy_branch_update( dsct->branches+i ); |
| 477 | } |
| 478 | |
| 479 | dsct->nr_branches--; |
| 480 | /* cleanup the slot not used anymore */ |
| 481 | memset( dsct->branches + dsct->nr_branches, 0, sizeof *dsct->branches ); |
| 482 | |
| 483 | return 0; |
| 484 | } |
| 485 | |
| 486 | |
| 487 | /*! \brief |
no test coverage detected