Revision 20574f551bcc5fcf0f0e20236af174754fa11363 authored by Jeff King on 22 February 2016, 22:44:39 UTC, committed by Junio C Hamano on 22 February 2016, 22:51:09 UTC
These functions transform an existing argv into one suitable
for exec-ing or spawning via git or a shell. We can use an
argv_array in each to avoid dealing with manual counting and
allocation.

This also makes the memory allocation more clear and fixes
some leaks. In prepare_shell_cmd, we would sometimes
allocate a new string with "$@" in it and sometimes not,
meaning the caller could not correctly free it. On the
non-Windows side, we are in a child process which will
exec() or exit() immediately, so the leak isn't a big deal.
On Windows, though, we use spawn() from the parent process,
and leak a string for each shell command we run. On top of
that, the Windows code did not free the allocated argv array
at all (but does for the prepare_git_cmd case!).

By switching both of these functions to write into an
argv_array, we can consistently free the result as
appropriate.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 50a6c8e
History
File Mode Size
bitmap.c -rw-r--r-- 5.0 KB
ewah_bitmap.c -rw-r--r-- 16.2 KB
ewah_io.c -rw-r--r-- 5.5 KB
ewah_rlw.c -rw-r--r-- 2.9 KB
ewok.h -rw-r--r-- 6.7 KB
ewok_rlw.h -rw-r--r-- 3.1 KB

back to top