summaryrefslogtreecommitdiff
path: root/src/diff_driver.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2014-12-21 15:31:03 +0000
committerCarlos Martín Nieto <cmn@dwim.me>2015-03-03 18:35:12 +0100
commit9a97f49e3aa15edc479fc590f4b28fc44c155c40 (patch)
treeb85de2d396b9d0d408f688212c0cdc74347ea7b3 /src/diff_driver.c
parent76f034180aee96fcc1fffd5267ccbc6ada68482a (diff)
downloadlibgit2-9a97f49e3aa15edc479fc590f4b28fc44c155c40.tar.gz
config: borrow refcounted referencescmn/config-borrow-entry
This changes the get_entry() method to return a refcounted version of the config entry, which you have to free when you're done. This allows us to avoid freeing the memory in which the entry is stored on a refresh, which may happen at any time for a live config. For this reason, get_string() has been forbidden on live configs and a new function get_string_buf() has been added, which stores the string in a git_buf which the user then owns. The functions which parse the string value takea advantage of the borrowing to parse safely and then release the entry.
Diffstat (limited to 'src/diff_driver.c')
-rw-r--r--src/diff_driver.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/diff_driver.c b/src/diff_driver.c
index 049e6ef2a..69eef0f7a 100644
--- a/src/diff_driver.c
+++ b/src/diff_driver.c
@@ -242,7 +242,7 @@ static int git_diff_driver_load(
khiter_t pos;
git_config *cfg = NULL;
git_buf name = GIT_BUF_INIT;
- const git_config_entry *ce;
+ git_config_entry *ce = NULL;
bool found_driver = false;
if ((reg = git_repository_driver_registry(repo)) == NULL)
@@ -341,6 +341,7 @@ static int git_diff_driver_load(
*out = drv;
done:
+ git_config_entry_free(ce);
git_buf_free(&name);
git_config_free(cfg);