MCPcopy Create free account
hub / github.com/KaisenAmin/c_std / algorithm_swap_ranges

Function algorithm_swap_ranges

algorithm/algorithm.c:1546–1558  ·  view source on GitHub ↗

* @brief Swaps ranges of elements between two arrays. * * @param first1 Pointer to the start of the first array. * @param first2 Pointer to the start of the second array. * @param num Number of elements to swap. * @param size Size of each element in bytes. */

Source from the content-addressed store, hash-verified

1544 * @param size Size of each element in bytes.
1545 */
1546void algorithm_swap_ranges(void *first1, void *first2, size_t num, size_t size) {
1547 ALGORITHM_LOG("[algorithm_swap_ranges] Info: Swapping %zu elements between two arrays of element size %zu.", num, size);
1548
1549 char *ptr1 = (char *)first1;
1550 char *ptr2 = (char *)first2;
1551
1552 for (size_t i = 0; i < num; ++i) {
1553 algorithm_swap(ptr1 + i * size, ptr2 + i * size, size);
1554 ALGORITHM_LOG("[algorithm_swap_ranges] Info: Swapped element %zu.", i);
1555 }
1556
1557 ALGORITHM_LOG("[algorithm_swap_ranges] Success: Swap ranges completed.");
1558}
1559
1560
1561/**

Callers

nothing calls this directly

Calls 1

algorithm_swapFunction · 0.85

Tested by

no test coverage detected