Skip to content

Commit 5aa1010

Browse files
committed
examples: general: narrow down scope of loop variables
1 parent 8572e22 commit 5aa1010

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

examples/general.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -644,10 +644,7 @@ static void index_walking(git_repository *repo)
644644
static void reference_listing(git_repository *repo)
645645
{
646646
git_strarray ref_list;
647-
const char *refname;
648-
git_reference *ref;
649647
unsigned i;
650-
char oid_hex[GIT_OID_HEXSZ+1];
651648

652649
printf("\n*Reference Listing*\n");
653650

@@ -662,7 +659,10 @@ static void reference_listing(git_repository *repo)
662659
git_reference_list(&ref_list, repo);
663660

664661
for (i = 0; i < ref_list.count; ++i) {
665-
memset(oid_hex, 0, sizeof(oid_hex));
662+
git_reference *ref;
663+
char oid_hex[GIT_OID_HEXSZ+1] = GIT_OID_HEX_ZERO;
664+
const char *refname;
665+
666666
refname = ref_list.strings[i];
667667
git_reference_lookup(&ref, repo, refname);
668668

@@ -679,6 +679,8 @@ static void reference_listing(git_repository *repo)
679679
fprintf(stderr, "Unexpected reference type\n");
680680
exit(1);
681681
}
682+
683+
git_reference_free(ref);
682684
}
683685

684686
git_strarray_free(&ref_list);

0 commit comments

Comments
 (0)