mirror of
https://gcc.gnu.org/git/gcc.git
synced 2026-02-21 19:35:28 -05:00
This patch introduces a new helper to swap the contents of two doubly-linked list wrappers. The new *_swap_lists operation exchanges the first, last, and size fields, allowing two lists to be swapped efficiently without iterating over their elements. This helper is intended for cases where the ownership of a list must be exchanged but swapping wrapper pointers is not possible. For simple references to lists, when wrappers are dynamically allocated, swapping the wrapper pointers themselves is sufficient and remains the preferred approach. This change adds the necessary declaration and definition macros to doubly-linked-list.h and integrates them into the set of mutative list operations. The testsuite is updated accordingly to cover the new functionality. include/ChangeLog: * doubly-linked-list.h (LINKED_LIST_SWAP_LISTS): Add new helper. (LINKED_LIST_DECL_SWAP_LISTS): Likewise. (LINKED_LIST_DEFN_SWAP_LISTS): Likewise. (LWRAPPERTYPE##_swap_lists): Likewise. libiberty/ChangeLog: * testsuite/test-doubly-linked-list.c: Update.