path: root/diff.c
diff options
authorYasushi SHOJI <>2005-08-13 10:58:56 (GMT)
committerJunio C Hamano <>2005-08-14 01:28:55 (GMT)
commit068eac91ce04b9aca163acb1927c3878c45d1a07 (patch)
tree87b828dfa09d9e6f700abee565b48613cf15d5c1 /diff.c
parente54c5ea93e0785dfd37fd9201797977a02ca0ddb (diff)
[PATCH] plug memory leak in diff.c::diff_free_filepair()
When I run git-diff-tree on big change, it seems the command eats so much memory. so I just put git under valgrind to see what's going on. diff_free_filespec_data() doesn't free diff_filespec itself. [jc: I ended up doing things slightly differently from Yasushi's patch. The original idea was to use free_filespec_data() only to free the data portion and keep useing the filespec itself, but no existing code seems to do things that way, so I just yanked that part out.] Signed-off-by: Yasushi SHOJI <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'diff.c')
1 files changed, 4 insertions, 5 deletions
diff --git a/diff.c b/diff.c
index 3e52fec..bb2a43b 100644
--- a/diff.c
+++ b/diff.c
@@ -405,14 +405,13 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only)
return 0;
-void diff_free_filespec_data(struct diff_filespec *s)
+void diff_free_filespec(struct diff_filespec *s)
if (s->should_free)
else if (s->should_munmap)
munmap(s->data, s->size);
- s->should_free = s->should_munmap = 0;
- s->data = NULL;
+ free(s);
static void prep_temp_blob(struct diff_tempfile *temp,
@@ -769,8 +768,8 @@ struct diff_filepair *diff_queue(struct diff_queue_struct *queue,
void diff_free_filepair(struct diff_filepair *p)
- diff_free_filespec_data(p->one);
- diff_free_filespec_data(p->two);
+ diff_free_filespec(p->one);
+ diff_free_filespec(p->two);