Valgrind: fix "definitely lost/still reachable" memory in test - test-xml2-is-file

Valgrind uses "still reachable" because of the call to exit()

==87185== 94 bytes in 1 blocks are still reachable in loss record 193 of 241
==87185==    at 0x4843828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==87185==    by 0x15C234: main (test-xml2-is-file.cpp:42)
==87185==
This commit is contained in:
Richard Cohen
2023-07-05 14:57:34 +01:00
parent d808fddc95
commit 2640911901

View File

@@ -19,7 +19,8 @@
\********************************************************************/
#include <config.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include "test-engine-stuff.h"
#include "io-gncxml-v2.h"
@@ -38,11 +39,9 @@ main (int argc, char** argv)
directory = "test-files/xml2";
}
auto size{strlen (directory) + 1 + strlen (FILENAME) + 1};
char* filename = static_cast<decltype (filename)> (malloc (size));
snprintf (filename, size, "%s/%s", directory, FILENAME);
do_test (gnc_is_xml_data_file_v2 (filename, NULL), "gnc_is_xml_data_file_v2");
auto filename = std::string{directory} + '/' + FILENAME;
do_test (gnc_is_xml_data_file_v2 (filename.c_str(), NULL), "gnc_is_xml_data_file_v2");
print_test_results ();
exit (get_rv ());
return get_rv ();
}