summaryrefslogtreecommitdiffstats
path: root/generic/tclClockFmt.c
diff options
context:
space:
mode:
authorsebres <sebres@users.sourceforge.net>2024-04-17 15:03:46 (GMT)
committersebres <sebres@users.sourceforge.net>2024-04-17 15:03:46 (GMT)
commit5bc0c6386aafc9f4bb188e7870574d048fd72613 (patch)
tree96499455beb8a1dd3887bf51cdd3ae9a8c0121d2 /generic/tclClockFmt.c
parent551d70451a01ed8cf74c263b336775c5954c3132 (diff)
parenta44403b68eafae765d1ae5f6d54091cfbfc84f47 (diff)
downloadtcl-5bc0c6386aafc9f4bb188e7870574d048fd72613.zip
tcl-5bc0c6386aafc9f4bb188e7870574d048fd72613.tar.gz
tcl-5bc0c6386aafc9f4bb188e7870574d048fd72613.tar.bz2
closes [167e0635db]: solves leaks, valgrind test, etc
Diffstat (limited to 'generic/tclClockFmt.c')
-rw-r--r--generic/tclClockFmt.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/generic/tclClockFmt.c b/generic/tclClockFmt.c
index 4ab2423..140ecdd 100644
--- a/generic/tclClockFmt.c
+++ b/generic/tclClockFmt.c
@@ -26,7 +26,6 @@ static void ClockFmtObj_UpdateString(Tcl_Obj *objPtr);
TCL_DECLARE_MUTEX(ClockFmtMutex); /* Serializes access to common format list. */
static void ClockFmtScnStorageDelete(ClockFmtScnStorage *fss);
-static void ClockFrmScnFinalize(void *);
#ifndef TCL_CLOCK_FULL_COMPAT
#define TCL_CLOCK_FULL_COMPAT 1
@@ -682,7 +681,7 @@ ClockFmtObj_FreeInternalRep(
Tcl_Obj *objPtr)
{
ClockFmtScnStorage *fss = ObjClockFmtScn(objPtr);
- if (fss != NULL) {
+ if (fss != NULL && initialized) {
Tcl_MutexLock(&ClockFmtMutex);
/* decrement object reference count of format/scan storage */
if (--fss->objRefCount <= 0) {
@@ -836,7 +835,6 @@ FindOrCreateFmtScnStorage(
&ClockFmtScnStorageHashKeyType);
initialized = 1;
- Tcl_CreateExitHandler(ClockFrmScnFinalize, NULL);
}
/* get or create entry (and alocate storage) */
@@ -3561,10 +3559,12 @@ ClockFrmScnClearCaches(void)
Tcl_MutexUnlock(&ClockFmtMutex);
}
-static void
-ClockFrmScnFinalize(
- TCL_UNUSED(void *))
+void
+ClockFrmScnFinalize()
{
+ if (!initialized) {
+ return;
+ }
Tcl_MutexLock(&ClockFmtMutex);
#if CLOCK_FMT_SCN_STORAGE_GC_SIZE > 0
/* clear GC */
@@ -3573,8 +3573,8 @@ ClockFrmScnFinalize(
ClockFmtScnStorage_GC.count = 0;
#endif
if (initialized) {
- Tcl_DeleteHashTable(&FmtScnHashTable);
initialized = 0;
+ Tcl_DeleteHashTable(&FmtScnHashTable);
}
Tcl_MutexUnlock(&ClockFmtMutex);
Tcl_MutexFinalize(&ClockFmtMutex);