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

Function reverse

algorithm/algorithm.c:43–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41
42
43static void reverse(void *first, void *last, size_t size) {
44 ALGORITHM_LOG("[reverse] Reversing elements between memory locations %p and %p, each of size %zu bytes.", first, last, size);
45
46 char *a = (char *)first;
47 char *b = (char *)last - size;
48
49 while (a < b) {
50 ALGORITHM_LOG("[reverse] Swapping elements at positions %p and %p.", a, b);
51 swap(a, b, size);
52 a += size;
53 b -= size;
54 }
55
56 ALGORITHM_LOG("[reverse] Completed reversing elements.");
57}
58
59
60#define SRT_ISORT_MAX 16 /* ranges this small are insertion-sorted */

Callers 2

Calls 1

swapFunction · 0.85

Tested by

no test coverage detected