If *changed_outputs is not supplied by the calling function, track the local allocation with a bool variable and free the allocation at the end of the function.