Commit 5aa10107 by Patrick Steinhardt

examples: general: narrow down scope of loop variables

parent 8572e225
...@@ -644,10 +644,7 @@ static void index_walking(git_repository *repo) ...@@ -644,10 +644,7 @@ static void index_walking(git_repository *repo)
static void reference_listing(git_repository *repo) static void reference_listing(git_repository *repo)
{ {
git_strarray ref_list; git_strarray ref_list;
const char *refname;
git_reference *ref;
unsigned i; unsigned i;
char oid_hex[GIT_OID_HEXSZ+1];
printf("\n*Reference Listing*\n"); printf("\n*Reference Listing*\n");
...@@ -662,7 +659,10 @@ static void reference_listing(git_repository *repo) ...@@ -662,7 +659,10 @@ static void reference_listing(git_repository *repo)
git_reference_list(&ref_list, repo); git_reference_list(&ref_list, repo);
for (i = 0; i < ref_list.count; ++i) { for (i = 0; i < ref_list.count; ++i) {
memset(oid_hex, 0, sizeof(oid_hex)); git_reference *ref;
char oid_hex[GIT_OID_HEXSZ+1] = GIT_OID_HEX_ZERO;
const char *refname;
refname = ref_list.strings[i]; refname = ref_list.strings[i];
git_reference_lookup(&ref, repo, refname); git_reference_lookup(&ref, repo, refname);
...@@ -679,6 +679,8 @@ static void reference_listing(git_repository *repo) ...@@ -679,6 +679,8 @@ static void reference_listing(git_repository *repo)
fprintf(stderr, "Unexpected reference type\n"); fprintf(stderr, "Unexpected reference type\n");
exit(1); exit(1);
} }
git_reference_free(ref);
} }
git_strarray_free(&ref_list); git_strarray_free(&ref_list);
......
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