Commit 382b668b by Patrick Steinhardt

khash: implement begin/end via functions instead of macros

Right now, the `git_*map_begin()` and `git_*map_end()` helpers are
implemented via macros which simply redirect to `kh_begin` and `kh_end`.
As these macros refer to members of the map structures, they make it
impossible to move the khash include into the implementation files.

Implement these helpers as real functions instead to further decouple
the headers from implementations.
parent ae765d00
......@@ -81,3 +81,14 @@ void git_offmap_delete(git_offmap *map, const git_off_t key)
if (git_offmap_valid_index(map, idx))
git_offmap_delete_at(map, idx);
}
size_t git_offmap_begin(git_offmap *map)
{
GIT_UNUSED(map);
return 0;
}
size_t git_offmap_end(git_offmap *map)
{
return map->n_buckets;
}
......@@ -40,6 +40,9 @@ int git_offmap_put(git_offmap *map, const git_off_t key, int *err);
void git_offmap_insert(git_offmap *map, const git_off_t key, void *value, int *rval);
void git_offmap_delete(git_offmap *map, const git_off_t key);
size_t git_offmap_begin(git_offmap *map);
size_t git_offmap_end(git_offmap *map);
#define git_offmap_foreach kh_foreach
#define git_offmap_foreach_value kh_foreach_value
......
......@@ -103,3 +103,14 @@ void git_oidmap_delete(git_oidmap *map, const git_oid *key)
if (git_oidmap_valid_index(map, idx))
git_oidmap_delete_at(map, idx);
}
size_t git_oidmap_begin(git_oidmap *map)
{
GIT_UNUSED(map);
return 0;
}
size_t git_oidmap_end(git_oidmap *map)
{
return map->n_buckets;
}
......@@ -43,9 +43,9 @@ int git_oidmap_put(git_oidmap *map, const git_oid *key, int *err);
void git_oidmap_insert(git_oidmap *map, const git_oid *key, void *value, int *rval);
void git_oidmap_delete(git_oidmap *map, const git_oid *key);
#define git_oidmap_foreach_value kh_foreach_value
size_t git_oidmap_begin(git_oidmap *map);
size_t git_oidmap_end(git_oidmap *map);
#define git_oidmap_begin kh_begin
#define git_oidmap_end kh_end
#define git_oidmap_foreach_value kh_foreach_value
#endif
......@@ -102,6 +102,17 @@ void git_strmap_delete(git_strmap *map, const char *key)
git_strmap_delete_at(map, idx);
}
size_t git_strmap_begin(git_strmap *map)
{
GIT_UNUSED(map);
return 0;
}
size_t git_strmap_end(git_strmap *map)
{
return map->n_buckets;
}
int git_strmap_next(
void **data,
git_strmap_iter* iter,
......
......@@ -45,8 +45,8 @@ void git_strmap_delete(git_strmap *map, const char *key);
#define git_strmap_foreach kh_foreach
#define git_strmap_foreach_value kh_foreach_value
#define git_strmap_begin kh_begin
#define git_strmap_end kh_end
size_t git_strmap_begin(git_strmap *map);
size_t git_strmap_end(git_strmap *map);
int git_strmap_next(
void **data,
......
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