aboutsummaryrefslogtreecommitdiff
path: root/sort.c
diff options
context:
space:
mode:
authorFranklin Wei <franklin@rockbox.org>2024-07-21 18:33:01 -0400
committerSimon Tatham <anakin@pobox.com>2024-07-31 23:29:00 +0100
commita2f7f962ced158dbceebbfc0c3dfbbc58b119e55 (patch)
treeb7e532d5060639f8090e0557ea46cbbe7acfcf5a /sort.c
parent5de69c22b0ff037f648a740a7c01869e78587df2 (diff)
downloadpuzzles-a2f7f962ced158dbceebbfc0c3dfbbc58b119e55.zip
puzzles-a2f7f962ced158dbceebbfc0c3dfbbc58b119e55.tar.gz
puzzles-a2f7f962ced158dbceebbfc0c3dfbbc58b119e55.tar.bz2
puzzles-a2f7f962ced158dbceebbfc0c3dfbbc58b119e55.tar.xz
Rename memswap() to swap_regions(). Consolidate duplicate implementations.
C99 reserves the mem* namespace for future expansion. Some Rockbox targets had issues with memswap() conflicting with another definition, so fix that.
Diffstat (limited to 'sort.c')
-rw-r--r--sort.c20
1 files changed, 1 insertions, 19 deletions
diff --git a/sort.c b/sort.c
index 6dff92f..e82f4ec 100644
--- a/sort.c
+++ b/sort.c
@@ -9,26 +9,8 @@
#include "puzzles.h"
-static void memswap(void *av, void *bv, size_t size)
-{
- char t[4096];
- char *a = (char *)av, *b = (char *)bv;
-
- while (size > 0) {
- size_t thissize = size < sizeof(t) ? size : sizeof(t);
-
- memcpy(t, a, thissize);
- memcpy(a, b, thissize);
- memcpy(b, t, thissize);
-
- size -= thissize;
- a += thissize;
- b += thissize;
- }
-}
-
#define PTR(i) ((char *)array + size * (i))
-#define SWAP(i,j) memswap(PTR(i), PTR(j), size)
+#define SWAP(i,j) swap_regions(PTR(i), PTR(j), size)
#define CMP(i,j) cmp(PTR(i), PTR(j), ctx)
#define LCHILD(i) (2*(i)+1)