Commit ee0c8618 by Edward Thomson

offmap: store off64_t's instead of git_off_t's

Prefer `off64_t` to `git_off_t` internally for visibility.
parent 8be12026
...@@ -14,9 +14,9 @@ ...@@ -14,9 +14,9 @@
#define kfree git__free #define kfree git__free
#include "khash.h" #include "khash.h"
__KHASH_TYPE(off, git_off_t, void *) __KHASH_TYPE(off, off64_t, void *)
__KHASH_IMPL(off, static kh_inline, git_off_t, void *, 1, kh_int64_hash_func, kh_int64_hash_equal) __KHASH_IMPL(off, static kh_inline, off64_t, void *, 1, kh_int64_hash_func, kh_int64_hash_equal)
int git_offmap_new(git_offmap **out) int git_offmap_new(git_offmap **out)
...@@ -42,7 +42,7 @@ size_t git_offmap_size(git_offmap *map) ...@@ -42,7 +42,7 @@ size_t git_offmap_size(git_offmap *map)
return kh_size(map); return kh_size(map);
} }
void *git_offmap_get(git_offmap *map, const git_off_t key) void *git_offmap_get(git_offmap *map, const off64_t key)
{ {
size_t idx = kh_get(off, map, key); size_t idx = kh_get(off, map, key);
if (idx == kh_end(map) || !kh_exist(map, idx)) if (idx == kh_end(map) || !kh_exist(map, idx))
...@@ -50,7 +50,7 @@ void *git_offmap_get(git_offmap *map, const git_off_t key) ...@@ -50,7 +50,7 @@ void *git_offmap_get(git_offmap *map, const git_off_t key)
return kh_val(map, idx); return kh_val(map, idx);
} }
int git_offmap_set(git_offmap *map, const git_off_t key, void *value) int git_offmap_set(git_offmap *map, const off64_t key, void *value)
{ {
size_t idx; size_t idx;
int rval; int rval;
...@@ -67,7 +67,7 @@ int git_offmap_set(git_offmap *map, const git_off_t key, void *value) ...@@ -67,7 +67,7 @@ int git_offmap_set(git_offmap *map, const git_off_t key, void *value)
return 0; return 0;
} }
int git_offmap_delete(git_offmap *map, const git_off_t key) int git_offmap_delete(git_offmap *map, const off64_t key)
{ {
khiter_t idx = kh_get(off, map, key); khiter_t idx = kh_get(off, map, key);
if (idx == kh_end(map)) if (idx == kh_end(map))
...@@ -76,12 +76,12 @@ int git_offmap_delete(git_offmap *map, const git_off_t key) ...@@ -76,12 +76,12 @@ int git_offmap_delete(git_offmap *map, const git_off_t key)
return 0; return 0;
} }
int git_offmap_exists(git_offmap *map, const git_off_t key) int git_offmap_exists(git_offmap *map, const off64_t key)
{ {
return kh_get(off, map, key) != kh_end(map); return kh_get(off, map, key) != kh_end(map);
} }
int git_offmap_iterate(void **value, git_offmap *map, size_t *iter, git_off_t *key) int git_offmap_iterate(void **value, git_offmap *map, size_t *iter, off64_t *key)
{ {
size_t i = *iter; size_t i = *iter;
......
...@@ -11,11 +11,11 @@ ...@@ -11,11 +11,11 @@
#include "git2/types.h" #include "git2/types.h"
/** A map with `git_off_t`s as key. */ /** A map with `off64_t`s as key. */
typedef struct kh_off_s git_offmap; typedef struct kh_off_s git_offmap;
/** /**
* Allocate a new `git_off_t` map. * Allocate a new `off64_t` map.
* *
* @param out Pointer to the map that shall be allocated. * @param out Pointer to the map that shall be allocated.
* @return 0 on success, an error code if allocation has failed. * @return 0 on success, an error code if allocation has failed.
...@@ -59,7 +59,7 @@ size_t git_offmap_size(git_offmap *map); ...@@ -59,7 +59,7 @@ size_t git_offmap_size(git_offmap *map);
* @param key key to search for * @param key key to search for
* @return value associated with the given key or NULL if the key was not found * @return value associated with the given key or NULL if the key was not found
*/ */
void *git_offmap_get(git_offmap *map, const git_off_t key); void *git_offmap_get(git_offmap *map, const off64_t key);
/** /**
* Set the entry for key to value. * Set the entry for key to value.
...@@ -74,7 +74,7 @@ void *git_offmap_get(git_offmap *map, const git_off_t key); ...@@ -74,7 +74,7 @@ void *git_offmap_get(git_offmap *map, const git_off_t key);
* @return zero if the key was successfully set, a negative error * @return zero if the key was successfully set, a negative error
* code otherwise * code otherwise
*/ */
int git_offmap_set(git_offmap *map, const git_off_t key, void *value); int git_offmap_set(git_offmap *map, const off64_t key, void *value);
/** /**
* Delete an entry from the map. * Delete an entry from the map.
...@@ -88,7 +88,7 @@ int git_offmap_set(git_offmap *map, const git_off_t key, void *value); ...@@ -88,7 +88,7 @@ int git_offmap_set(git_offmap *map, const git_off_t key, void *value);
* such key was found, a negative code in case of an * such key was found, a negative code in case of an
* error * error
*/ */
int git_offmap_delete(git_offmap *map, const git_off_t key); int git_offmap_delete(git_offmap *map, const off64_t key);
/** /**
* Check whether a key exists in the given map. * Check whether a key exists in the given map.
...@@ -97,7 +97,7 @@ int git_offmap_delete(git_offmap *map, const git_off_t key); ...@@ -97,7 +97,7 @@ int git_offmap_delete(git_offmap *map, const git_off_t key);
* @param key key to search for * @param key key to search for
* @return 0 if the key has not been found, 1 otherwise * @return 0 if the key has not been found, 1 otherwise
*/ */
int git_offmap_exists(git_offmap *map, const git_off_t key); int git_offmap_exists(git_offmap *map, const off64_t key);
/** /**
* Iterate over entries of the map. * Iterate over entries of the map.
...@@ -118,7 +118,7 @@ int git_offmap_exists(git_offmap *map, const git_off_t key); ...@@ -118,7 +118,7 @@ int git_offmap_exists(git_offmap *map, const git_off_t key);
* GIT_ITEROVER if no entries are left. A negative error * GIT_ITEROVER if no entries are left. A negative error
* code otherwise. * code otherwise.
*/ */
int git_offmap_iterate(void **value, git_offmap *map, size_t *iter, git_off_t *key); int git_offmap_iterate(void **value, git_offmap *map, size_t *iter, off64_t *key);
#define git_offmap_foreach(h, kvar, vvar, code) { size_t __i = 0; \ #define git_offmap_foreach(h, kvar, vvar, code) { size_t __i = 0; \
while (git_offmap_iterate((void **) &(vvar), h, &__i, &(kvar)) == 0) { \ while (git_offmap_iterate((void **) &(vvar), h, &__i, &(kvar)) == 0) { \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment