Skip to content

Commit

Permalink
examples: Free the git_config and git_config_entry after use
Browse files Browse the repository at this point in the history
  • Loading branch information
257 committed Sep 24, 2021
1 parent 1369010 commit 581cfbd
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions examples/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ static int config_get(git_config *cfg, const char *key)
}

puts(entry->value);

/* Free the git_config_entry after use with `git_config_entry_free()`. */
git_config_entry_free(entry);

return 0;
}

Expand Down Expand Up @@ -57,6 +61,11 @@ int lg2_config(git_repository *repo, int argc, char **argv)
error = 1;
}

/**
* The configuration file must be freed once it's no longer
* being used by the user.
*/
git_config_free(cfg);
out:
return error;
}

0 comments on commit 581cfbd

Please sign in to comment.