Win32: don't copy the environment twice when spawning child processes
commit0659189110f7eeb25e1d4360df8c9cdd818a4ca4
authorKarsten Blees <blees@dcon.de>
Sat, 14 Jan 2012 23:57:14 +0000 (15 00:57 +0100)
committerJohannes Schindelin <johannes.schindelin@gmx.de>
Fri, 30 Mar 2012 18:44:00 +0000 (30 13:44 -0500)
tree86ed3feb369d34628e0018f39646c02e8f900c30
parent4999c7731dca9528d666df2497a2b9698087b77f
Win32: don't copy the environment twice when spawning child processes

When spawning child processes via start_command(), the environment and all
environment entries are copied twice. First by make_augmented_environ /
copy_environ to merge with child_process.env. Then a second time by
make_environment_block to create a sorted environment block string as
required by CreateProcess.

Move the merge logic to make_environment_block so that we only need to copy
the environment once. This changes semantics of the env parameter: it now
expects a delta (such as child_process.env) rather than a full environment.
This is not a problem as the parameter is only used by start_command()
(all other callers previously passed char **environ, and now pass NULL).

The merge logic no longer xstrdup()s the environment strings, so do_putenv
must not free them. Add a parameter to distinguish this from normal putenv.

Remove the now unused make_augmented_environ / free_environ API.

Signed-off-by: Karsten Blees <blees@dcon.de>
compat/mingw.c
compat/mingw.h
run-command.c