summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: dcda361)
raw | patch | inline | side by side (parent: dcda361)
author | Junio C Hamano <gitster@pobox.com> | |
Tue, 1 Sep 2009 09:18:29 +0000 (02:18 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 1 Sep 2009 15:02:51 +0000 (08:02 -0700) |
Instead of allocating a temporary array imglen[], copying contents to it
from another array img->line[], and then using imglen[], use the value
from img->line[], whose value does not change during the whole process.
This incidentally removes a use of C99 variable length array, which some
older compilers apparently are not happy with.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
from another array img->line[], and then using imglen[], use the value
from img->line[], whose value does not change during the whole process.
This incidentally removes a use of C99 variable length array, which some
older compilers apparently are not happy with.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-apply.c | patch | blob | history |
diff --git a/builtin-apply.c b/builtin-apply.c
index ae11b41ef29215fcb2147387676228ca6965d86d..c8372a0a8051c331e671aee588b8ea0632ad6430 100644 (file)
--- a/builtin-apply.c
+++ b/builtin-apply.c
size_t imgoff = 0;
size_t preoff = 0;
size_t postlen = postimage->len;
- size_t imglen[preimage->nr];
for (i = 0; i < preimage->nr; i++) {
size_t prelen = preimage->line[i].len;
+ size_t imglen = img->line[try_lno+i].len;
- imglen[i] = img->line[try_lno+i].len;
- if (!fuzzy_matchlines(
- img->buf + try + imgoff, imglen[i],
- preimage->buf + preoff, prelen))
+ if (!fuzzy_matchlines(img->buf + try + imgoff, imglen,
+ preimage->buf + preoff, prelen))
return 0;
if (preimage->line[i].flag & LINE_COMMON)
- postlen += imglen[i] - prelen;
- imgoff += imglen[i];
+ postlen += imglen - prelen;
+ imgoff += imglen;
preoff += prelen;
}
fixed_buf = xmalloc(imgoff);
memcpy(fixed_buf, img->buf + try, imgoff);
for (i = 0; i < preimage->nr; i++)
- preimage->line[i].len = imglen[i];
+ preimage->line[i].len = img->line[try_lno+i].len;
/*
* Update the preimage buffer and the postimage context lines.