#include <stdint.h>
#include <stdlib.h>
+#ifndef GIT_WIN32
+#include <common.h>
+#endif
/**
* An array-of-pointers implementation of Python's Timsort
* Based on code by Christopher Swenson under the MIT license
static void bisort(void **dst, size_t start, size_t size, cmp_ptr_t cmp)
{
size_t i;
+ void *x;
+ int location;
for (i = start; i < size; i++) {
int j;
continue;
/* Else we need to find the right place, shift everything over, and squeeze in */
- void *x = dst[i];
- int location = binsearch(dst, x, i, cmp);
+ x = dst[i];
+ location = binsearch(dst, x, i, cmp);
for (j = i - 1; j >= location; j--) {
dst[j + 1] = dst[j];
}
bisort(&dst[curr], len, run, cmp);\
len = run;\
}\
- run_stack[stack_curr++] = (struct tsort_run) {curr, len};\
+ run_stack[stack_curr].start = curr;\
+ run_stack[stack_curr++].length = len;\
curr += len;\
if (curr == (ssize_t)size) {\
/* finish up */ \
}\
while (0)
-
void git__tsort(void **dst, size_t size, cmp_ptr_t cmp)
{
struct tsort_store _store, *store = &_store;
} \
} while (0)
-extern int git__tsort(void **b, size_t n, int (*cmp)(const void *, const void *));
+extern void git__tsort(void **dst, size_t size, int (*cmp)(const void *, const void *));
extern void **git__bsearch(const void *key, void **base, size_t nmemb,
int (*compar)(const void *, const void *));