Call git_pathdup() rather than xstrdup(git_path("..."))

In addition to updating the two xstrdup(git_path("...")) call sites with git_pathdup(), we also fix a memory leak by freeing the memory allocated to the ADD_EDIT.patch 'file' in the edit_patch() function. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ramsay Jones committed Sep 4, 2012 at 18:30 UTC d292bfaf356338b41e14e40ce4dbd6b9c8d600ec
2 files changed +3 -2
bisect.c
+1 -1
@@ -833,7 +833,7 @@ static int check_ancestors(const char *prefix)
833 */
834 static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)
835 {
836 - char *filename = xstrdup(git_path("BISECT_ANCESTORS_OK"));
836 + char *filename = git_pathdup("BISECT_ANCESTORS_OK");
837 struct stat st;
838 int fd;
839
builtin/add.c
+2 -1
@@ -260,7 +260,7 @@ int interactive_add(int argc, const char **argv, const char *prefix, int patch)
260
261 static int edit_patch(int argc, const char **argv, const char *prefix)
262 {
263 - char *file = xstrdup(git_path("ADD_EDIT.patch"));
263 + char *file = git_pathdup("ADD_EDIT.patch");
264 const char *apply_argv[] = { "apply", "--recount", "--cached",
265 NULL, NULL };
266 struct child_process child;
@@ -303,6 +303,7 @@ static int edit_patch(int argc, const char **argv, const char *prefix)
303 die (_("Could not apply '%s'"), file);
304
305 unlink(file);
306 + free(file);
307 return 0;
308 }
309