summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3bf7886)
raw | patch | inline | side by side (parent: 3bf7886)
author | Bo Yang <struggleyb.nku@gmail.com> | |
Fri, 7 May 2010 04:52:27 +0000 (21:52 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 7 May 2010 16:34:27 +0000 (09:34 -0700) |
Refactor the diff_queue_struct code, this macro help
to reset the structure.
Signed-off-by: Bo Yang <struggleyb.nku@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
to reset the structure.
Signed-off-by: Bo Yang <struggleyb.nku@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c | patch | blob | history | |
diffcore-break.c | patch | blob | history | |
diffcore-pickaxe.c | patch | blob | history | |
diffcore-rename.c | patch | blob | history | |
diffcore.h | patch | blob | history |
index e40c1271da3f2ea433b55f770408e8d3a0f8a521..4a350e365e5f4d0c61977546e620bf6b79679dd5 100644 (file)
--- a/diff.c
+++ b/diff.c
void diff_setup(struct diff_options *options)
{
memset(options, 0, sizeof(*options));
+ memset(&diff_queued_diff, 0, sizeof(diff_queued_diff));
options->file = stdout;
diff_free_filepair(q->queue[i]);
free(q->queue);
- q->queue = NULL;
- q->nr = q->alloc = 0;
+ DIFF_QUEUE_CLEAR(q);
return result;
}
diff_free_filepair(q->queue[i]);
free_queue:
free(q->queue);
- q->queue = NULL;
- q->nr = q->alloc = 0;
+ DIFF_QUEUE_CLEAR(q);
if (options->close_file)
fclose(options->file);
int i;
struct diff_queue_struct *q = &diff_queued_diff;
struct diff_queue_struct outq;
- outq.queue = NULL;
- outq.nr = outq.alloc = 0;
+ DIFF_QUEUE_CLEAR(&outq);
if (!filter)
return;
int i;
struct diff_queue_struct *q = &diff_queued_diff;
struct diff_queue_struct outq;
- outq.queue = NULL;
- outq.nr = outq.alloc = 0;
+ DIFF_QUEUE_CLEAR(&outq);
for (i = 0; i < q->nr; i++) {
struct diff_filepair *p = q->queue[i];
diff --git a/diffcore-break.c b/diffcore-break.c
index 3a7b60a037b2e3c869afe76a23b671cfd5311338..44f8678d22ea466b0867591429bbcc3285cdaf91 100644 (file)
--- a/diffcore-break.c
+++ b/diffcore-break.c
if (!merge_score)
merge_score = DEFAULT_MERGE_SCORE;
- outq.nr = outq.alloc = 0;
- outq.queue = NULL;
+ DIFF_QUEUE_CLEAR(&outq);
for (i = 0; i < q->nr; i++) {
struct diff_filepair *p = q->queue[i];
struct diff_queue_struct outq;
int i, j;
- outq.nr = outq.alloc = 0;
- outq.queue = NULL;
+ DIFF_QUEUE_CLEAR(&outq);
for (i = 0; i < q->nr; i++) {
struct diff_filepair *p = q->queue[i];
diff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c
index d0ef8397008824fb5139680856e3229ecf2c4eb1..929de15aa9228099b3a772be788d746e440a9e8c 100644 (file)
--- a/diffcore-pickaxe.c
+++ b/diffcore-pickaxe.c
int i, has_changes;
regex_t regex, *regexp = NULL;
struct diff_queue_struct outq;
- outq.queue = NULL;
- outq.nr = outq.alloc = 0;
+ DIFF_QUEUE_CLEAR(&outq);
if (opts & DIFF_PICKAXE_REGEX) {
int err;
diff --git a/diffcore-rename.c b/diffcore-rename.c
index d6fd3cacd6de4757994c61903dd07e0c4d74a9e9..df41be56deab60d4d39a45920a1e62b05d0474f6 100644 (file)
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
/* At this point, we have found some renames and copies and they
* are recorded in rename_dst. The original list is still in *q.
*/
- outq.queue = NULL;
- outq.nr = outq.alloc = 0;
+ DIFF_QUEUE_CLEAR(&outq);
for (i = 0; i < q->nr; i++) {
struct diff_filepair *p = q->queue[i];
struct diff_filepair *pair_to_free = NULL;
diff --git a/diffcore.h b/diffcore.h
index fcd00bf27aee4e1f2823f05ab3dba1d3c70a509d..5d05deaf68b7c44a98456e9c0e12a7af2230f116 100644 (file)
--- a/diffcore.h
+++ b/diffcore.h
int alloc;
int nr;
};
+#define DIFF_QUEUE_CLEAR(q) \
+ do { \
+ (q)->queue = NULL; \
+ (q)->nr = (q)->alloc = 0; \
+ } while(0);
extern struct diff_queue_struct diff_queued_diff;
extern struct diff_filepair *diff_queue(struct diff_queue_struct *,