Skip to content

Commit 581cfbd

Browse files
committed
examples: Free the git_config and git_config_entry after use
1 parent 1369010 commit 581cfbd

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

examples/config.c

+9
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ static int config_get(git_config *cfg, const char *key)
2626
}
2727

2828
puts(entry->value);
29+
30+
/* Free the git_config_entry after use with `git_config_entry_free()`. */
31+
git_config_entry_free(entry);
32+
2933
return 0;
3034
}
3135

@@ -57,6 +61,11 @@ int lg2_config(git_repository *repo, int argc, char **argv)
5761
error = 1;
5862
}
5963

64+
/**
65+
* The configuration file must be freed once it's no longer
66+
* being used by the user.
67+
*/
68+
git_config_free(cfg);
6069
out:
6170
return error;
6271
}

0 commit comments

Comments
 (0)