christophercrouzet / rexo

Neat single-file cross-platform unit testing framework for C/C++.
The Unlicense
28 stars 6 forks source link

fix memory leak #5

Closed default-writer closed 4 years ago

default-writer commented 4 years ago

Example project:

https://github.com/funcelot/c

before:

==19423== ==19423== HEAP SUMMARY: ==19423== in use at exit: 392 bytes in 1 blocks ==19423== total heap usage: 35 allocs, 34 frees, 2,616 bytes allocated ==19423== ==19423== 392 bytes in 1 blocks are definitely lost in loss record 1 of 1 ==19423== at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) ==19423== by 0x10B7F7: rxrun_test_cases (rexo.h:4846) ==19423== by 0x10BA9C: rxrun_registered_test_cases (rexo.h:4918) ==19423== by 0x10FC53: rx_run (rexo.h:6044) ==19423== by 0x110734: main (main.c:295) ==19423== ==19423== LEAK SUMMARY: ==19423== definitely lost: 392 bytes in 1 blocks ==19423== indirectly lost: 0 bytes in 0 blocks ==19423== possibly lost: 0 bytes in 0 blocks ==19423== still reachable: 0 bytes in 0 blocks ==19423== suppressed: 0 bytes in 0 blocks ==19423== ==19423== For lists of detected and suppressed errors, rerun with: -s ==19423== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

after:

==16591== ==16591== HEAP SUMMARY: ==16591== in use at exit: 0 bytes in 0 blocks ==16591== total heap usage: 35 allocs, 35 frees, 2,616 bytes allocated ==16591== ==16591== All heap blocks were freed -- no leaks are possible ==16591== ==16591== For lists of detected and suppressed errors, rerun with: -s ==16591== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)