From d1f346931a7db577d24dca4f4ff5f81103bcc191 Mon Sep 17 00:00:00 2001 From: nulltoken Date: Tue, 9 Aug 2011 12:07:47 +0200 Subject: [PATCH] util: Add git__strcmp_cb() wrapper We don't want direct pointers to the CRT on Windows, we may get stdcall conflicts. --- src/refs.c | 8 +++----- src/transport_local.c | 9 +-------- src/util.c | 13 +++++++++++++ src/util.h | 2 ++ 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/refs.c b/src/refs.c index beb98a780..2e5466886 100644 --- a/src/refs.c +++ b/src/refs.c @@ -503,7 +503,7 @@ static int packed_load(git_repository *repo) ref_cache->packfile = git_hashtable_alloc( default_table_size, reftable_hash, - (git_hash_keyeq_ptr)strcmp); + (git_hash_keyeq_ptr)(&git__strcmp_cb)); if (ref_cache->packfile == NULL) { error = GIT_ENOMEM; @@ -1609,7 +1609,7 @@ int git_repository__refcache_init(git_refcache *refs) refs->loose_cache = git_hashtable_alloc( default_table_size, reftable_hash, - (git_hash_keyeq_ptr)strcmp); + (git_hash_keyeq_ptr)(&git__strcmp_cb)); /* packfile loaded lazily */ refs->packfile = NULL; @@ -1752,6 +1752,4 @@ int git_reference__normalize_name(char *buffer_out, size_t out_size, const char int git_reference__normalize_name_oid(char *buffer_out, size_t out_size, const char *name) { return normalize_name(buffer_out, out_size, name, 1); -} - - +} \ No newline at end of file diff --git a/src/transport_local.c b/src/transport_local.c index 350f2ea4a..4e0ac6f31 100644 --- a/src/transport_local.c +++ b/src/transport_local.c @@ -14,13 +14,6 @@ typedef struct { git_vector *refs; } transport_local; -static int cmp_refs(const void *a, const void *b) -{ - const char *stra = (const char *)a; - const char *strb = (const char *)b; - return strcmp(stra, strb); -} - /* * Try to open the url as a git directory. The direction doesn't * matter in this case because we're calulating the heads ourselves. @@ -147,7 +140,7 @@ static int local_ls(git_transport *transport, git_headarray *array) return error; /* Sort the references first */ - git__tsort((void **)refs.strings, refs.count, &cmp_refs); + git__tsort((void **)refs.strings, refs.count, &git__strcmp_cb); /* Add HEAD */ error = add_ref(GIT_HEAD_FILE, repo, vec); diff --git a/src/util.c b/src/util.c index a51cbe6d8..57274b0ce 100644 --- a/src/util.c +++ b/src/util.c @@ -355,3 +355,16 @@ void **git__bsearch(const void *key, void **base, size_t nmemb, int (*compar)(co return NULL; } +/** + * A strcmp wrapper + * + * We don't want direct pointers to the CRT on Windows, we may + * get stdcall conflicts. + */ +int git__strcmp_cb(const void *a, const void *b) +{ + const char *stra = (const char *)a; + const char *strb = (const char *)b; + + return strcmp(stra, strb); +} \ No newline at end of file diff --git a/src/util.h b/src/util.h index e78b2cd5e..18929af8e 100644 --- a/src/util.h +++ b/src/util.h @@ -120,4 +120,6 @@ extern void git__tsort(void **dst, size_t size, int (*cmp)(const void *, const v extern void **git__bsearch(const void *key, void **base, size_t nmemb, int (*compar)(const void *, const void *)); +extern int git__strcmp_cb(const void *a, const void *b); + #endif /* INCLUDE_util_h__ */ -- 2.39.5