This introduces a new function to free a common data structure,
and plugs some leaks.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
+void diff_free_filepair(struct diff_filepair *p)
+{
+ diff_free_filespec_data(p->one);
+ diff_free_filespec_data(p->two);
+ free(p);
+}
+
static void diff_flush_raw(struct diff_filepair *p,
int line_termination,
int inter_name_termination)
static void diff_flush_raw(struct diff_filepair *p,
int line_termination,
int inter_name_termination)
- for (i = 0; i < q->nr; i++) {
- struct diff_filepair *p = q->queue[i];
- diff_free_filespec_data(p->one);
- diff_free_filespec_data(p->two);
- free(p);
- }
+ for (i = 0; i < q->nr; i++)
+ diff_free_filepair(q->queue[i]);
free(q->queue);
q->queue = NULL;
q->nr = q->alloc = 0;
free(q->queue);
q->queue = NULL;
q->nr = q->alloc = 0;
matches_pathspec(p->two->path, spec, speccnt))
diff_q(&outq, p);
else
matches_pathspec(p->two->path, spec, speccnt))
diff_q(&outq, p);
else
}
free(q->queue);
*q = outq;
}
free(q->queue);
*q = outq;
contains(p->two, needle, len))
diff_q(&outq, p);
if (onum == outq.nr)
contains(p->two, needle, len))
diff_q(&outq, p);
if (onum == outq.nr)
}
free(q->queue);
*q = outq;
}
free(q->queue);
*q = outq;
- if (pair_to_free) {
- diff_free_filespec_data(pair_to_free->one);
- diff_free_filespec_data(pair_to_free->two);
- free(pair_to_free);
- }
+ if (pair_to_free)
+ diff_free_filepair(pair_to_free);
}
diff_debug_queue("done copying original", &outq);
}
diff_debug_queue("done copying original", &outq);
(S_ISREG(mode) ? (S_IFREG | ce_permissions(mode)) : \
S_ISLNK(mode) ? S_IFLNK : S_IFDIR)
(S_ISREG(mode) ? (S_IFREG | ce_permissions(mode)) : \
S_ISLNK(mode) ? S_IFLNK : S_IFDIR)
+extern void diff_free_filepair(struct diff_filepair *);
+
extern int diff_unmodified_pair(struct diff_filepair *);
struct diff_queue_struct {
extern int diff_unmodified_pair(struct diff_filepair *);
struct diff_queue_struct {