Revert "[PATCH] plug memory leak in diff.c::diff_free_filepair()"
This reverts 068eac91ce04b9aca163acb1927c3878c45d1a07 commit.
Junio C Hamano committed
Sep 14, 2005 at 14:06 UTC
19397b4521bcc27eb224413fb71519223b94290f
3 files changed
+8
-7
diff.c
+5
-4
@@ -402,13 +402,14 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only)
402
return 0;
403
}
404
405
-void diff_free_filespec(struct diff_filespec *s)
405
+void diff_free_filespec_data(struct diff_filespec *s)
406
{
407
if (s->should_free)
408
free(s->data);
409
else if (s->should_munmap)
410
munmap(s->data, s->size);
411
- free(s);
411
+ s->should_free = s->should_munmap = 0;
412
+ s->data = NULL;
413
}
414
415
static void prep_temp_blob(struct diff_tempfile *temp,
@@ -767,8 +768,8 @@ struct diff_filepair *diff_queue(struct diff_queue_struct *queue,
768
769
void diff_free_filepair(struct diff_filepair *p)
770
{
770
- diff_free_filespec(p->one);
771
- diff_free_filespec(p->two);
771
+ diff_free_filespec_data(p->one);
772
+ diff_free_filespec_data(p->two);
773
free(p);
774
}
775
diffcore-break.c
+2
-2
@@ -231,8 +231,8 @@ static void merge_broken(struct diff_filepair *p,
231
232
dp = diff_queue(outq, d->one, c->two);
233
dp->score = p->score;
234
- diff_free_filespec(d->two);
235
- diff_free_filespec(c->one);
234
+ diff_free_filespec_data(d->two);
235
+ diff_free_filespec_data(c->one);
236
free(d);
237
free(c);
238
}
diffcore.h
+1
-1
@@ -43,7 +43,7 @@ extern void fill_filespec(struct diff_filespec *, const unsigned char *,
43
unsigned short);
44
45
extern int diff_populate_filespec(struct diff_filespec *, int);
46
-extern void diff_free_filespec(struct diff_filespec *);
46
+extern void diff_free_filespec_data(struct diff_filespec *);
47
48
struct diff_filepair {
49
struct diff_filespec *one;