From 9fe19d6cf98534ecf6e014231f56a80e13a2902d Mon Sep 17 00:00:00 2001 From: Richard Cohen Date: Fri, 7 Jul 2023 11:53:24 +0100 Subject: [PATCH 1/3] Move potentially unused "SCM zone" variable into the #ifdef --- common/base-typemaps.i | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/common/base-typemaps.i b/common/base-typemaps.i index 39f12638a6..fbae4c3e98 100644 --- a/common/base-typemaps.i +++ b/common/base-typemaps.i @@ -71,7 +71,6 @@ typedef char gchar; %typemap(in) struct tm * (struct tm t) { SCM tm = $input; - SCM zone; t.tm_sec = scm_to_int(SCM_SIMPLE_VECTOR_REF(tm, 0)); t.tm_min = scm_to_int(SCM_SIMPLE_VECTOR_REF(tm, 1)); t.tm_hour = scm_to_int(SCM_SIMPLE_VECTOR_REF(tm, 2)); @@ -83,7 +82,7 @@ typedef char gchar; t.tm_isdst = scm_to_int(SCM_SIMPLE_VECTOR_REF(tm, 8)); %#ifdef HAVE_STRUCT_TM_GMTOFF t.tm_gmtoff = scm_to_int(SCM_SIMPLE_VECTOR_REF(tm, 9)); - zone = SCM_SIMPLE_VECTOR_REF(tm, 10); + SCM zone = SCM_SIMPLE_VECTOR_REF(tm, 10); t.tm_zone = SCM_UNBNDP(zone) ? NULL : scm_to_locale_string(zone); %#endif $1 = &t; From 75f49aaec509d8feb2a272a19db5d8cfa40b0bb1 Mon Sep 17 00:00:00 2001 From: Richard Cohen Date: Thu, 20 Jul 2023 15:46:17 +0100 Subject: [PATCH 2/3] 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) ... --- common/base-typemaps.i | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/common/base-typemaps.i b/common/base-typemaps.i index fbae4c3e98..ebd1355d4d 100644 --- a/common/base-typemaps.i +++ b/common/base-typemaps.i @@ -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); From 8a91fa8deb61302b0edc54aaadfd4ab37c9f72db Mon Sep 17 00:00:00 2001 From: John Ralls Date: Sun, 10 Sep 2023 15:06:46 -0700 Subject: [PATCH 3/3] Remove defective and fortunately unused typemap. --- common/base-typemaps.i | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/common/base-typemaps.i b/common/base-typemaps.i index ebd1355d4d..e70a365a56 100644 --- a/common/base-typemaps.i +++ b/common/base-typemaps.i @@ -121,30 +121,6 @@ typedef char gchar; %typemap(newfree) struct tm * "gnc_tm_free($1);" -%typemap(argout) struct tm * { - struct tm* t = $1; - SCM tm = $input; - if (t == NULL) - { - SCM_SIMPLE_VECTOR_SET(tm, 0, scm_from_int(t->tm_sec)); - SCM_SIMPLE_VECTOR_SET(tm, 1, scm_from_int(t->tm_min)); - SCM_SIMPLE_VECTOR_SET(tm, 2, scm_from_int(t->tm_hour)); - SCM_SIMPLE_VECTOR_SET(tm, 3, scm_from_int(t->tm_mday)); - SCM_SIMPLE_VECTOR_SET(tm, 4, scm_from_int(t->tm_mon)); - SCM_SIMPLE_VECTOR_SET(tm, 5, scm_from_int(t->tm_year)); - SCM_SIMPLE_VECTOR_SET(tm, 6, scm_from_int(t->tm_wday)); - SCM_SIMPLE_VECTOR_SET(tm, 7, scm_from_int(t->tm_yday)); - SCM_SIMPLE_VECTOR_SET(tm, 8, scm_from_int(t->tm_isdst)); -%#ifdef HAVE_STRUCT_TM_GMTOFF - SCM_SIMPLE_VECTOR_SET(tm, 9, scm_from_long(t->tm_gmtoff)); - SCM_SIMPLE_VECTOR_SET(tm, 10, scm_from_locale_string(t->tm_zone?t->tm_zone:"Unset")); -%#else - SCM_SIMPLE_VECTOR_SET(tm, 9, scm_from_long(0)); - SCM_SIMPLE_VECTOR_SET(tm, 10, scm_from_locale_string("GMT")); -%#endif - } - } - %define GLIST_HELPER_INOUT(ListType, ElemSwigType) %typemap(in) ListType * { SCM list = $input;