mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-04 15:07:41 +00:00
commit
cc427158d4
@ -33,14 +33,14 @@
|
|||||||
# include "win32/pthread.h"
|
# include "win32/pthread.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# define snprintf _snprintf
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
# include <unistd.h>
|
|
||||||
|
|
||||||
|
# include <unistd.h>
|
||||||
# ifdef GIT_THREADS
|
# ifdef GIT_THREADS
|
||||||
# include <pthread.h>
|
# include <pthread.h>
|
||||||
# endif
|
# endif
|
||||||
|
#define GIT_STDLIB_CALL
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "git2/types.h"
|
#include "git2/types.h"
|
||||||
|
@ -19,7 +19,7 @@ typedef uint64_t hashsig_state;
|
|||||||
|
|
||||||
#define HASHSIG_HEAP_SIZE ((1 << 7) - 1)
|
#define HASHSIG_HEAP_SIZE ((1 << 7) - 1)
|
||||||
|
|
||||||
typedef int (*hashsig_cmp)(const void *a, const void *b);
|
typedef int (GIT_STDLIB_CALL *hashsig_cmp)(const void *a, const void *b);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int size, asize;
|
int size, asize;
|
||||||
@ -53,13 +53,13 @@ static void hashsig_heap_init(hashsig_heap *h, hashsig_cmp cmp)
|
|||||||
h->cmp = cmp;
|
h->cmp = cmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hashsig_cmp_max(const void *a, const void *b)
|
static int GIT_STDLIB_CALL hashsig_cmp_max(const void *a, const void *b)
|
||||||
{
|
{
|
||||||
hashsig_t av = *(const hashsig_t *)a, bv = *(const hashsig_t *)b;
|
hashsig_t av = *(const hashsig_t *)a, bv = *(const hashsig_t *)b;
|
||||||
return (av < bv) ? -1 : (av > bv) ? 1 : 0;
|
return (av < bv) ? -1 : (av > bv) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hashsig_cmp_min(const void *a, const void *b)
|
static int GIT_STDLIB_CALL hashsig_cmp_min(const void *a, const void *b)
|
||||||
{
|
{
|
||||||
hashsig_t av = *(const hashsig_t *)a, bv = *(const hashsig_t *)b;
|
hashsig_t av = *(const hashsig_t *)a, bv = *(const hashsig_t *)b;
|
||||||
return (av > bv) ? -1 : (av < bv) ? 1 : 0;
|
return (av > bv) ? -1 : (av < bv) ? 1 : 0;
|
||||||
@ -183,8 +183,8 @@ static void hashsig_initial_window(
|
|||||||
/* insert initial hash if we just finished */
|
/* insert initial hash if we just finished */
|
||||||
|
|
||||||
if (win_len == HASHSIG_HASH_WINDOW) {
|
if (win_len == HASHSIG_HASH_WINDOW) {
|
||||||
hashsig_heap_insert(&sig->mins, state);
|
hashsig_heap_insert(&sig->mins, (hashsig_t)state);
|
||||||
hashsig_heap_insert(&sig->maxs, state);
|
hashsig_heap_insert(&sig->maxs, (hashsig_t)state);
|
||||||
sig->considered = 1;
|
sig->considered = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,8 +224,8 @@ static int hashsig_add_hashes(
|
|||||||
state = (state * HASHSIG_HASH_SHIFT) & HASHSIG_HASH_MASK;
|
state = (state * HASHSIG_HASH_SHIFT) & HASHSIG_HASH_MASK;
|
||||||
state = (state + ch) & HASHSIG_HASH_MASK;
|
state = (state + ch) & HASHSIG_HASH_MASK;
|
||||||
|
|
||||||
hashsig_heap_insert(&sig->mins, state);
|
hashsig_heap_insert(&sig->mins, (hashsig_t)state);
|
||||||
hashsig_heap_insert(&sig->maxs, state);
|
hashsig_heap_insert(&sig->maxs, (hashsig_t)state);
|
||||||
sig->considered++;
|
sig->considered++;
|
||||||
|
|
||||||
prog->window[prog->win_pos] = ch;
|
prog->window[prog->win_pos] = ch;
|
||||||
@ -307,7 +307,7 @@ int git_hashsig_create_fromfile(
|
|||||||
|
|
||||||
while (!error) {
|
while (!error) {
|
||||||
if ((buflen = p_read(fd, buf, sizeof(buf))) <= 0) {
|
if ((buflen = p_read(fd, buf, sizeof(buf))) <= 0) {
|
||||||
if ((error = buflen) < 0)
|
if ((error = (int)buflen) < 0)
|
||||||
giterr_set(GITERR_OS,
|
giterr_set(GITERR_OS,
|
||||||
"Read error on '%s' calculating similarity hashes", path);
|
"Read error on '%s' calculating similarity hashes", path);
|
||||||
break;
|
break;
|
||||||
|
@ -37,6 +37,15 @@
|
|||||||
/* MSVC doesn't define ssize_t at all */
|
/* MSVC doesn't define ssize_t at all */
|
||||||
typedef SSIZE_T ssize_t;
|
typedef SSIZE_T ssize_t;
|
||||||
|
|
||||||
|
/* define snprintf using variadic macro support if available */
|
||||||
|
#if _MSC_VER >= 1400
|
||||||
|
# define snprintf(BUF, SZ, FMT, ...) _snprintf_s(BUF, SZ, _TRUNCATE, FMT, __VA_ARGS__)
|
||||||
|
#else
|
||||||
|
# define snprintf _snprintf
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define GIT_STDLIB_CALL __cdecl
|
||||||
|
|
||||||
#endif /* INCLUDE_msvc_compat__ */
|
#endif /* INCLUDE_msvc_compat__ */
|
||||||
|
@ -375,7 +375,8 @@ int p_vsnprintf(char *buffer, size_t count, const char *format, va_list argptr)
|
|||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if (count == 0 || (len = _vsnprintf(buffer, count, format, argptr)) < 0)
|
if (count == 0 ||
|
||||||
|
(len = _vsnprintf_s(buffer, count, _TRUNCATE, format, argptr)) < 0)
|
||||||
return _vscprintf(format, argptr);
|
return _vscprintf(format, argptr);
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
|
Loading…
Reference in New Issue
Block a user