mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-03 17:57:25 +00:00
Don't typedef a pointer
Make the iterator structure opaque and make sure it compiles.
This commit is contained in:
parent
a603c19157
commit
4d588d9713
@ -61,7 +61,7 @@ typedef struct {
|
||||
} git_config_entry;
|
||||
|
||||
typedef int (*git_config_foreach_cb)(const git_config_entry *, void *);
|
||||
typedef struct git_config_backend_iter* git_config_backend_iter;
|
||||
typedef struct git_config_backend_iter git_config_backend_iter;
|
||||
|
||||
typedef enum {
|
||||
GIT_CVAR_FALSE = 0,
|
||||
|
@ -37,7 +37,7 @@ struct git_config_backend {
|
||||
int (*del)(struct git_config_backend *, const char *key);
|
||||
int (*iterator_new)(git_config_backend_iter **, struct git_config_backend *);
|
||||
void (*iterator_free)(git_config_backend_iter *);
|
||||
int (*next)(git_config_backend_iter *, git_config_entry *, struct git_config_backend *);
|
||||
int (*next)(git_config_entry *, git_config_backend_iter *);
|
||||
int (*refresh)(struct git_config_backend *);
|
||||
void (*free)(struct git_config_backend *);
|
||||
};
|
||||
|
@ -328,7 +328,7 @@ int git_config_backend_foreach_match(
|
||||
void *data)
|
||||
{
|
||||
git_config_entry entry;
|
||||
git_config_backend_iter iter;
|
||||
git_config_backend_iter* iter;
|
||||
regex_t regex;
|
||||
int result = 0;
|
||||
|
||||
@ -343,7 +343,7 @@ int git_config_backend_foreach_match(
|
||||
if (backend->iterator_new(&iter, backend) < 0)
|
||||
return 0;
|
||||
|
||||
while(!(backend->next(&iter, &entry, backend) < 0)) {
|
||||
while(!(backend->next(&entry, iter) < 0)) {
|
||||
/* skip non-matching keys if regexp was provided */
|
||||
if (regexp && regexec(®ex, entry.name, 0, NULL, 0) != 0)
|
||||
continue;
|
||||
|
@ -24,6 +24,11 @@ struct git_config {
|
||||
git_vector files;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
git_config_backend *backend;
|
||||
unsigned int flags;
|
||||
} git_config_backend_iter;
|
||||
|
||||
extern int git_config_find_global_r(git_buf *global_config_path);
|
||||
extern int git_config_find_xdg_r(git_buf *system_config_path);
|
||||
extern int git_config_find_system_r(git_buf *system_config_path);
|
||||
|
@ -28,6 +28,8 @@ typedef struct cvar_t {
|
||||
} cvar_t;
|
||||
|
||||
typedef struct git_config_file_iter {
|
||||
git_config_backend *backend;
|
||||
unsigned int flags;
|
||||
git_strmap_iter iter;
|
||||
cvar_t* next;
|
||||
} git_config_file_iter;
|
||||
@ -254,7 +256,7 @@ static void backend_free(git_config_backend *_backend)
|
||||
}
|
||||
|
||||
static int config_iterator_new(
|
||||
git_config_backend_iter *iter,
|
||||
git_config_backend_iter **iter,
|
||||
struct git_config_backend* backend)
|
||||
{
|
||||
diskfile_backend *b = (diskfile_backend *)backend;
|
||||
@ -266,6 +268,7 @@ static int config_iterator_new(
|
||||
*it = git__calloc(1, sizeof(git_config_file_iter));
|
||||
GITERR_CHECK_ALLOC(it);
|
||||
|
||||
(*it)->backend = backend;
|
||||
(*it)->iter = git_strmap_begin(b->values);
|
||||
(*it)->next = NULL;
|
||||
|
||||
@ -273,18 +276,17 @@ static int config_iterator_new(
|
||||
}
|
||||
|
||||
static void config_iterator_free(
|
||||
git_config_backend_iter iter)
|
||||
git_config_backend_iter* iter)
|
||||
{
|
||||
git__free(iter);
|
||||
}
|
||||
|
||||
static int config_next(
|
||||
git_config_backend_iter *iter,
|
||||
git_config_entry* entry,
|
||||
struct git_config_backend* backend)
|
||||
static int config_iterator_next(
|
||||
git_config_entry *entry,
|
||||
git_config_backend_iter *iter)
|
||||
{
|
||||
diskfile_backend *b = (diskfile_backend *)backend;
|
||||
git_config_file_iter *it = *((git_config_file_iter**) iter);
|
||||
diskfile_backend *b = (diskfile_backend *)it->backend;
|
||||
int err;
|
||||
cvar_t * var;
|
||||
const char* key;
|
||||
@ -611,7 +613,7 @@ int git_config_file__ondisk(git_config_backend **out, const char *path)
|
||||
backend->parent.del = config_delete;
|
||||
backend->parent.iterator_new = config_iterator_new;
|
||||
backend->parent.iterator_free = config_iterator_free;
|
||||
backend->parent.next = config_next;
|
||||
backend->parent.next = config_iterator_next;
|
||||
backend->parent.refresh = config_refresh;
|
||||
backend->parent.free = backend_free;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user