Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
bdcc4611
Commit
bdcc4611
authored
Jul 07, 2011
by
nulltoken
Committed by
Vicent Marti
Jul 07, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix MSVC compilation warnings
parent
de18f276
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
6 deletions
+11
-6
src/tsort.c
+9
-4
src/util.h
+1
-1
tests/t00-core.c
+1
-1
No files found.
src/tsort.c
View file @
bdcc4611
...
...
@@ -3,6 +3,9 @@
#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
...
...
@@ -89,6 +92,8 @@ static int binsearch(void **dst, const void *x, size_t size, cmp_ptr_t cmp)
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
;
...
...
@@ -97,8 +102,8 @@ static void bisort(void **dst, size_t start, size_t size, cmp_ptr_t cmp)
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
];
}
...
...
@@ -323,7 +328,8 @@ static ssize_t collapse(void **dst, struct tsort_run *stack, ssize_t stack_curr,
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 */
\
...
...
@@ -341,7 +347,6 @@ static ssize_t collapse(void **dst, struct tsort_run *stack, ssize_t stack_curr,
}\
while (0)
void
git__tsort
(
void
**
dst
,
size_t
size
,
cmp_ptr_t
cmp
)
{
struct
tsort_store
_store
,
*
store
=
&
_store
;
...
...
src/util.h
View file @
bdcc4611
...
...
@@ -118,7 +118,7 @@ extern int git__fnmatch(const char *pattern, const char *name, int flags);
} \
} 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
*
));
...
...
tests/t00-core.c
View file @
bdcc4611
...
...
@@ -75,7 +75,7 @@ END_TEST
static
int
test_cmp
(
const
void
*
a
,
const
void
*
b
)
{
return
a
-
b
;
return
(
int
)
a
-
(
int
)
b
;
}
BEGIN_TEST
(
vector2
,
"remove duplicates"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment