diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-03-10 11:13:43 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-03-10 11:13:43 -0800 |
commit | b7a6ec609ff10652541e7f716fcecf7865b94b23 (patch) | |
tree | 92c449ecb681311c3713a1d2be178776b05bd259 /builtin/grep.c | |
parent | Merge branch 'jk/more-comments-on-textconv' into maint (diff) | |
parent | compat/mingw: brown paper bag fix for 50a6c8e (diff) | |
download | tgif-b7a6ec609ff10652541e7f716fcecf7865b94b23.tar.xz |
Merge branch 'jk/tighten-alloc' into maint
* jk/tighten-alloc: (23 commits)
compat/mingw: brown paper bag fix for 50a6c8e
ewah: convert to REALLOC_ARRAY, etc
convert ewah/bitmap code to use xmalloc
diff_populate_gitlink: use a strbuf
transport_anonymize_url: use xstrfmt
git-compat-util: drop mempcpy compat code
sequencer: simplify memory allocation of get_message
test-path-utils: fix normalize_path_copy output buffer size
fetch-pack: simplify add_sought_entry
fast-import: simplify allocation in start_packfile
write_untracked_extension: use FLEX_ALLOC helper
prepare_{git,shell}_cmd: use argv_array
use st_add and st_mult for allocation size computation
convert trivial cases to FLEX_ARRAY macros
use xmallocz to avoid size arithmetic
convert trivial cases to ALLOC_ARRAY
convert manual allocations to argv_array
argv-array: add detach function
add helpers for allocating flex-array structs
harden REALLOC_ARRAY and xcalloc against size_t overflow
...
Diffstat (limited to 'builtin/grep.c')
-rw-r--r-- | builtin/grep.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/builtin/grep.c b/builtin/grep.c index 3ba35ecf93..65c02010c7 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -354,17 +354,17 @@ static void append_path(struct grep_opt *opt, const void *data, size_t len) static void run_pager(struct grep_opt *opt, const char *prefix) { struct string_list *path_list = opt->output_priv; - const char **argv = xmalloc(sizeof(const char *) * (path_list->nr + 1)); + struct child_process child = CHILD_PROCESS_INIT; int i, status; for (i = 0; i < path_list->nr; i++) - argv[i] = path_list->items[i].string; - argv[path_list->nr] = NULL; + argv_array_push(&child.args, path_list->items[i].string); + child.dir = prefix; + child.use_shell = 1; - status = run_command_v_opt_cd_env(argv, RUN_USING_SHELL, prefix, NULL); + status = run_command(&child); if (status) exit(status); - free(argv); } static int grep_cache(struct grep_opt *opt, const struct pathspec *pathspec, int cached) |