• Jeff King's avatar
    run-command: store an optional argv_array · c460c0ec
    Jeff King authored
    All child_process structs need to point to an argv. For
    flexibility, we do not mandate the use of a dynamic
    argv_array. However, because the child_process does not own
    the memory, this can make memory management with a
    separate argv_array difficult.
    
    For example, if a function calls start_command but not
    finish_command, the argv memory must persist. The code needs
    to arrange to clean up the argv_array separately after
    finish_command runs. As a result, some of our code in this
    situation just leaks the memory.
    
    To help such cases, this patch adds a built-in argv_array to
    the child_process, which gets cleaned up automatically (both
    in finish_command and when start_command fails).  Callers
    may use it if they choose, but can continue to use the raw
    argv if they wish.
    Signed-off-by: default avatarJeff King <peff@peff.net>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    c460c0ec
run-command.h 3.16 KB