Skip to content
  • Martin Ågren's avatar
    object_array: use `object_array_clear()`, not `free()` · dcb572ab
    Martin Ågren authored and Junio C Hamano's avatar Junio C Hamano committed
    
    
    Instead of freeing `foo.objects` for an object array `foo` (sometimes
    conditionally), call `object_array_clear(&foo)`. This means we don't
    poke as much into the implementation, which is already a good thing, but
    also that we release the individual entries as well, thereby fixing at
    least one memory-leak (in diff-lib.c).
    
    If someone is holding on to a pointer to an element's `name` or `path`,
    that is now a dangling pointer, i.e., we'd be turning an unpleasant
    situation into an outright bug. To the best of my understanding no such
    long-term pointers are being taken.
    
    The way we handle `study` in builting/reflog.c still looks like it might
    leak. That will be addressed in the next commit.
    
    Signed-off-by: default avatarMartin Ågren <martin.agren@gmail.com>
    Reviewed-by: default avatarJeff King <peff@peff.net>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    dcb572ab