Valgrind: fix "definitely lost" memory in (gnc-mktime) - test-invoice-report-builtin-default

==158291== 6 bytes in 1 blocks are definitely lost in loss record 18 of 824
==158291==    at 0x4848C63: realloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==158291==    by 0x4A91473: scm_realloc (in /usr/lib/x86_64-linux-gnu/libguile-3.0.so.1.5.0)
==158291==    by 0x4AFF26B: scm_to_stringn (in /usr/lib/x86_64-linux-gnu/libguile-3.0.so.1.5.0)
==158291==    by 0x4CB473D: _wrap_gnc_mktime(scm_unused_struct*) (swig-engine.cpp:38703)
...
This commit is contained in:
Richard Cohen 2023-07-20 15:46:17 +01:00 committed by John Ralls
parent 9fe19d6cf9
commit 75f49aaec5

View File

@ -69,7 +69,7 @@ typedef char gchar;
%typemap(in) time64 * (time64 t) "t = scm_to_int64($input); $1 = &t;"
%typemap(out) time64 * " $result = ($1) ? scm_from_int64(*($1)) : SCM_BOOL_F; "
%typemap(in) struct tm * (struct tm t) {
%typemap(in) struct tm * (struct tm t, char *tzone) {
SCM tm = $input;
t.tm_sec = scm_to_int(SCM_SIMPLE_VECTOR_REF(tm, 0));
t.tm_min = scm_to_int(SCM_SIMPLE_VECTOR_REF(tm, 1));
@ -83,10 +83,16 @@ typedef char gchar;
%#ifdef HAVE_STRUCT_TM_GMTOFF
t.tm_gmtoff = scm_to_int(SCM_SIMPLE_VECTOR_REF(tm, 9));
SCM zone = SCM_SIMPLE_VECTOR_REF(tm, 10);
t.tm_zone = SCM_UNBNDP(zone) ? NULL : scm_to_locale_string(zone);
tzone = SCM_UNBNDP(zone) ? NULL : scm_to_locale_string(zone);
t.tm_zone = tzone;
%#endif
$1 = &t;
}
%typemap(freearg) struct tm * {
%#ifdef HAVE_STRUCT_TM_GMTOFF
free(tzone$argnum);
%#endif
}
%typemap(out) struct tm * {
SCM tm = scm_c_make_vector(11, SCM_UNDEFINED);