Skip to content

Commit

Permalink
Revert "[PATCH] plug memory leak in diff.c::diff_free_filepair()"
Browse files Browse the repository at this point in the history
This reverts 068eac9 commit.
  • Loading branch information
Junio C Hamano committed Sep 14, 2005
1 parent 705a714 commit 19397b4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,13 +402,14 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only)
return 0;
}

void diff_free_filespec(struct diff_filespec *s)
void diff_free_filespec_data(struct diff_filespec *s)
{
if (s->should_free)
free(s->data);
else if (s->should_munmap)
munmap(s->data, s->size);
free(s);
s->should_free = s->should_munmap = 0;
s->data = NULL;
}

static void prep_temp_blob(struct diff_tempfile *temp,
Expand Down Expand Up @@ -767,8 +768,8 @@ struct diff_filepair *diff_queue(struct diff_queue_struct *queue,

void diff_free_filepair(struct diff_filepair *p)
{
diff_free_filespec(p->one);
diff_free_filespec(p->two);
diff_free_filespec_data(p->one);
diff_free_filespec_data(p->two);
free(p);
}

Expand Down
4 changes: 2 additions & 2 deletions diffcore-break.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ static void merge_broken(struct diff_filepair *p,

dp = diff_queue(outq, d->one, c->two);
dp->score = p->score;
diff_free_filespec(d->two);
diff_free_filespec(c->one);
diff_free_filespec_data(d->two);
diff_free_filespec_data(c->one);
free(d);
free(c);
}
Expand Down
2 changes: 1 addition & 1 deletion diffcore.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ extern void fill_filespec(struct diff_filespec *, const unsigned char *,
unsigned short);

extern int diff_populate_filespec(struct diff_filespec *, int);
extern void diff_free_filespec(struct diff_filespec *);
extern void diff_free_filespec_data(struct diff_filespec *);

struct diff_filepair {
struct diff_filespec *one;
Expand Down

0 comments on commit 19397b4

Please sign in to comment.