alandefreitas / clang-unformat

A simple tool to infer a .clang-format file from existing code
Boost Software License 1.0
58 stars 13 forks source link

Fixes EdlibAlignResult memory leak #12

Closed CarlosNihelton closed 1 year ago

CarlosNihelton commented 1 year ago

Hi Alan, thanks for this nice piece of software!

edlib README quite misleading in its first snipped of code suggesting a memory leak. Downwards it explains that the result of edlibAlign must be freed. See https://github.com/Martinsos/edlib#handling-result-of-edlibalign

It's a C API after all. This PR wraps the EdlibAlignResult into a local struct to ensure calling edlibFreeAlignResult at scope exit.

The screenshot below shows heaptrack analyzing the output data of the clang-unformat program running with the same parameters mentioned in #3 .

Screenshot from 2023-02-05 07-56-48

Fixes #3

alandefreitas commented 1 year ago

Thanks