This is an automated email from the ASF dual-hosted git repository. swebb2066 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
The following commit(s) were added to refs/heads/master by this push: new 295facf2 Remove unnecessary static data in the next ABI version (#507) 295facf2 is described below commit 295facf273893a6358cfecef88fbfcbef46c186c Author: Stephen Webb <stephen.w...@ieee.org> AuthorDate: Fri Jul 4 10:33:06 2025 +1000 Remove unnecessary static data in the next ABI version (#507) --- src/main/cpp/aprinitializer.cpp | 10 +++++++--- src/main/cpp/fileinputstream.cpp | 8 ++------ src/main/cpp/fileoutputstream.cpp | 10 +++------- src/main/cpp/threadspecificdata.cpp | 2 ++ src/main/include/log4cxx/helpers/aprinitializer.h | 8 +++----- src/main/include/log4cxx/helpers/fileinputstream.h | 6 +++--- src/main/include/log4cxx/helpers/fileoutputstream.h | 6 +++--- 7 files changed, 23 insertions(+), 27 deletions(-) diff --git a/src/main/cpp/aprinitializer.cpp b/src/main/cpp/aprinitializer.cpp index 8e62af21..36119e2a 100644 --- a/src/main/cpp/aprinitializer.cpp +++ b/src/main/cpp/aprinitializer.cpp @@ -23,16 +23,18 @@ #include <assert.h> #include <log4cxx/helpers/threadspecificdata.h> #include <apr_thread_proc.h> -#include <log4cxx/helpers/filewatchdog.h> #include <log4cxx/helpers/date.h> #include <log4cxx/helpers/loglog.h> -#include <list> +#include <vector> #include <algorithm> +#include <mutex> using namespace LOG4CXX_NS::helpers; using namespace LOG4CXX_NS; +#if LOG4CXX_ABI_VERSION <= 15 bool APRInitializer::isDestructed = false; +#endif using IdentifiedObject = std::pair<size_t, ObjectPtr>; @@ -68,7 +70,7 @@ void tlsDestructImpl(void* ptr) #if LOG4CXX_ABI_VERSION <= 15 extern "C" void tlsDestruct(void* ptr) { - return tlsDestructImpl(ptr); + tlsDestructImpl(ptr); } #endif @@ -103,7 +105,9 @@ APRInitializer::APRInitializer() : APRInitializer::~APRInitializer() { +#if LOG4CXX_ABI_VERSION <= 15 isDestructed = true; +#endif #if APR_HAS_THREADS std::lock_guard<std::mutex> lock(m_priv->mutex); apr_threadkey_private_delete(m_priv->tlsKey); diff --git a/src/main/cpp/fileinputstream.cpp b/src/main/cpp/fileinputstream.cpp index f9755669..3a1ac091 100644 --- a/src/main/cpp/fileinputstream.cpp +++ b/src/main/cpp/fileinputstream.cpp @@ -19,12 +19,8 @@ #include <log4cxx/helpers/fileinputstream.h> #include <log4cxx/helpers/exception.h> #include <log4cxx/helpers/bytebuffer.h> +#include <log4cxx/helpers/pool.h> #include <apr_file_io.h> -#include <log4cxx/helpers/transcoder.h> -#if !defined(LOG4CXX) - #define LOG4CXX 1 -#endif -#include <log4cxx/helpers/aprinitializer.h> using namespace LOG4CXX_NS; using namespace LOG4CXX_NS::helpers; @@ -82,7 +78,7 @@ FileInputStream::FileInputStream(const File& aFile) : FileInputStream::~FileInputStream() { - if (m_priv->fileptr != NULL && !APRInitializer::isDestructed) + if (m_priv->fileptr) { apr_file_close(m_priv->fileptr); } diff --git a/src/main/cpp/fileoutputstream.cpp b/src/main/cpp/fileoutputstream.cpp index b93f71ec..d75634f5 100644 --- a/src/main/cpp/fileoutputstream.cpp +++ b/src/main/cpp/fileoutputstream.cpp @@ -17,14 +17,10 @@ #include <log4cxx/logstring.h> #include <log4cxx/helpers/fileoutputstream.h> +#include <log4cxx/helpers/pool.h> #include <log4cxx/helpers/exception.h> #include <log4cxx/helpers/bytebuffer.h> #include <apr_file_io.h> -#include <log4cxx/helpers/transcoder.h> -#if !defined(LOG4CXX) - #define LOG4CXX 1 -#endif -#include <log4cxx/helpers/aprinitializer.h> using namespace LOG4CXX_NS; using namespace LOG4CXX_NS::helpers; @@ -81,7 +77,7 @@ apr_file_t* FileOutputStream::open(const LogString& filename, FileOutputStream::~FileOutputStream() { - if (m_priv->fileptr != NULL && !APRInitializer::isDestructed) + if (m_priv->fileptr) { apr_file_close(m_priv->fileptr); } @@ -89,7 +85,7 @@ FileOutputStream::~FileOutputStream() void FileOutputStream::close(Pool& /* p */) { - if (m_priv->fileptr != NULL) + if (m_priv->fileptr) { apr_status_t stat = apr_file_close(m_priv->fileptr); diff --git a/src/main/cpp/threadspecificdata.cpp b/src/main/cpp/threadspecificdata.cpp index 3eafce02..ffaf1566 100644 --- a/src/main/cpp/threadspecificdata.cpp +++ b/src/main/cpp/threadspecificdata.cpp @@ -31,6 +31,8 @@ #include <sstream> #include <algorithm> #include <thread> +#include <mutex> +#include <list> using namespace LOG4CXX_NS; using namespace LOG4CXX_NS::helpers; diff --git a/src/main/include/log4cxx/helpers/aprinitializer.h b/src/main/include/log4cxx/helpers/aprinitializer.h index aab18595..18e9c7e0 100644 --- a/src/main/include/log4cxx/helpers/aprinitializer.h +++ b/src/main/include/log4cxx/helpers/aprinitializer.h @@ -23,34 +23,32 @@ #endif #include <log4cxx/helpers/object.h> -#include <list> -#include <log4cxx/helpers/date.h> #include <log4cxx/helpers/widelife.h> extern "C" { struct apr_threadkey_t; struct apr_pool_t; } - -#include <mutex> #include <functional> namespace LOG4CXX_NS { namespace helpers { +#if LOG4CXX_ABI_VERSION <= 15 class FileWatchdog; +#endif class APRInitializer { public: #if LOG4CXX_ABI_VERSION <= 15 static log4cxx_time_t initialize(); + static bool isDestructed; #endif static apr_pool_t* getRootPool(); static log4cxx_time_t getStartTime(); static apr_threadkey_t* getTlsKey(); - static bool isDestructed; #if LOG4CXX_ABI_VERSION <= 15 /** diff --git a/src/main/include/log4cxx/helpers/fileinputstream.h b/src/main/include/log4cxx/helpers/fileinputstream.h index 5b900f22..4a40b4ed 100644 --- a/src/main/include/log4cxx/helpers/fileinputstream.h +++ b/src/main/include/log4cxx/helpers/fileinputstream.h @@ -20,7 +20,6 @@ #include <log4cxx/helpers/inputstream.h> #include <log4cxx/file.h> -#include <log4cxx/helpers/pool.h> #include <memory> namespace LOG4CXX_NS @@ -81,9 +80,10 @@ class LOG4CXX_EXPORT FileInputStream : public InputStream private: - FileInputStream(const FileInputStream&); + FileInputStream(const FileInputStream&) = delete; + FileInputStream(FileInputStream&&) = delete; - FileInputStream& operator=(const FileInputStream&); + FileInputStream& operator=(const FileInputStream&) = delete; void open(const LogString&); }; diff --git a/src/main/include/log4cxx/helpers/fileoutputstream.h b/src/main/include/log4cxx/helpers/fileoutputstream.h index 58069418..a1b15c4e 100644 --- a/src/main/include/log4cxx/helpers/fileoutputstream.h +++ b/src/main/include/log4cxx/helpers/fileoutputstream.h @@ -20,7 +20,6 @@ #include <log4cxx/helpers/outputstream.h> #include <log4cxx/file.h> -#include <log4cxx/helpers/pool.h> namespace LOG4CXX_NS @@ -55,8 +54,9 @@ class LOG4CXX_EXPORT FileOutputStream : public OutputStream apr_file_t* getFilePtr() const; private: - FileOutputStream(const FileOutputStream&); - FileOutputStream& operator=(const FileOutputStream&); + FileOutputStream(const FileOutputStream&) = delete; + FileOutputStream(FileOutputStream&&) = delete; + FileOutputStream& operator=(const FileOutputStream&) = delete; static apr_file_t* open(const LogString& fn, bool append, LOG4CXX_NS::helpers::Pool& p); };