mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-20 23:51:29 -07:00
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.
This commit is contained in:

committed by
Simon Tatham

parent
5de69c22b0
commit
a2f7f962ce
20
sort.c
20
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)
|
||||
|
Reference in New Issue
Block a user