summaryrefslogtreecommitdiff
path: root/line-log.c
diff options
context:
space:
mode:
Diffstat (limited to 'line-log.c')
-rw-r--r--line-log.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/line-log.c b/line-log.c
index af6e2f799e..bbe31ed6fb 100644
--- a/line-log.c
+++ b/line-log.c
@@ -14,6 +14,7 @@
#include "graph.h"
#include "userdiff.h"
#include "line-log.h"
+#include "argv-array.h"
static void range_set_grow(struct range_set *rs, size_t extra)
{
@@ -521,7 +522,7 @@ static void fill_line_ends(struct diff_filespec *spec, long *lines,
if (diff_populate_filespec(spec, 0))
die("Cannot read blob %s", sha1_to_hex(spec->sha1));
- ends = xmalloc(size * sizeof(*ends));
+ ALLOC_ARRAY(ends, size);
ends[cur++] = 0;
data = spec->data;
while (num < spec->size) {
@@ -746,22 +747,17 @@ void line_log_init(struct rev_info *rev, const char *prefix, struct string_list
add_line_range(rev, commit, range);
if (!rev->diffopt.detect_rename) {
- int i, count = 0;
- struct line_log_data *r = range;
+ struct line_log_data *r;
+ struct argv_array array = ARGV_ARRAY_INIT;
const char **paths;
- while (r) {
- count++;
- r = r->next;
- }
- paths = xmalloc((count+1)*sizeof(char *));
- r = range;
- for (i = 0; i < count; i++) {
- paths[i] = xstrdup(r->path);
- r = r->next;
- }
- paths[count] = NULL;
+
+ for (r = range; r; r = r->next)
+ argv_array_push(&array, r->path);
+ paths = argv_array_detach(&array);
+
parse_pathspec(&rev->diffopt.pathspec, 0,
PATHSPEC_PREFER_FULL, "", paths);
+ /* strings are now owned by pathspec */
free(paths);
}
}
@@ -1146,9 +1142,9 @@ static int process_ranges_merge_commit(struct rev_info *rev, struct commit *comm
if (nparents > 1 && rev->first_parent_only)
nparents = 1;
- diffqueues = xmalloc(nparents * sizeof(*diffqueues));
- cand = xmalloc(nparents * sizeof(*cand));
- parents = xmalloc(nparents * sizeof(*parents));
+ ALLOC_ARRAY(diffqueues, nparents);
+ ALLOC_ARRAY(cand, nparents);
+ ALLOC_ARRAY(parents, nparents);
p = commit->parents;
for (i = 0; i < nparents; i++) {