summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a00d7d1)
raw | patch | inline | side by side (parent: a00d7d1)
author | Junio C Hamano <junkio@cox.net> | |
Fri, 27 May 2005 22:50:30 +0000 (15:50 -0700) | ||
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | |
Sun, 29 May 2005 18:17:43 +0000 (11:17 -0700) |
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>
and plugs some leaks.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
diff.c | patch | blob | history | |
diffcore-pathspec.c | patch | blob | history | |
diffcore-pickaxe.c | patch | blob | history | |
diffcore-rename.c | patch | blob | history | |
diffcore.h | patch | blob | history |
index f745cdd6e8bcd356c8b6f26accdd26b8b78be056..680b521a8bcab5355306ba6367d4c7f2cbd75f5c 100644 (file)
--- a/diff.c
+++ b/diff.c
return dp;
}
+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)
break;
}
}
- 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;
diff --git a/diffcore-pathspec.c b/diffcore-pathspec.c
index fd11822aaf1a543f14f074d6975f5e55ef95c73a..c460b2e56d3e6fe26f9e78ba3a877dc5417e8590 100644 (file)
--- a/diffcore-pathspec.c
+++ b/diffcore-pathspec.c
matches_pathspec(p->two->path, spec, speccnt))
diff_q(&outq, p);
else
- free(p);
+ diff_free_filepair(p);
}
free(q->queue);
*q = outq;
diff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c
index fea62d51a090e22e43938245747e409ea7ede883..491900929ff07ccf6ee6372368e51a3ca061cdab 100644 (file)
--- a/diffcore-pickaxe.c
+++ b/diffcore-pickaxe.c
contains(p->two, needle, len))
diff_q(&outq, p);
if (onum == outq.nr)
- free(p);
+ diff_free_filepair(p);
}
free(q->queue);
*q = outq;
diff --git a/diffcore-rename.c b/diffcore-rename.c
index 81e4d9df3dcb0ba8646fa8f902f6ac918d04bdb7..39a53a88bac16642ebee718ff47b6a8ecab3e82f 100644 (file)
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
else
pair_to_free = p;
}
- 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 --git a/diffcore.h b/diffcore.h
index ee1955bf384d83e0c168844e5eefc83a2f993fb9..0f82bd933ec2f173d588383ede37890da562578e 100644 (file)
--- a/diffcore.h
+++ b/diffcore.h
(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 {