Skip to content

Commit 295facf

Browse files
authored
Remove unnecessary static data in the next ABI version (#507)
1 parent acc690a commit 295facf

File tree

7 files changed

+23
-27
lines changed

7 files changed

+23
-27
lines changed

src/main/cpp/aprinitializer.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,18 @@
2323
#include <assert.h>
2424
#include <log4cxx/helpers/threadspecificdata.h>
2525
#include <apr_thread_proc.h>
26-
#include <log4cxx/helpers/filewatchdog.h>
2726
#include <log4cxx/helpers/date.h>
2827
#include <log4cxx/helpers/loglog.h>
29-
#include <list>
28+
#include <vector>
3029
#include <algorithm>
30+
#include <mutex>
3131

3232
using namespace LOG4CXX_NS::helpers;
3333
using namespace LOG4CXX_NS;
3434

35+
#if LOG4CXX_ABI_VERSION <= 15
3536
bool APRInitializer::isDestructed = false;
37+
#endif
3638

3739
using IdentifiedObject = std::pair<size_t, ObjectPtr>;
3840

@@ -68,7 +70,7 @@ void tlsDestructImpl(void* ptr)
6870
#if LOG4CXX_ABI_VERSION <= 15
6971
extern "C" void tlsDestruct(void* ptr)
7072
{
71-
return tlsDestructImpl(ptr);
73+
tlsDestructImpl(ptr);
7274
}
7375
#endif
7476

@@ -103,7 +105,9 @@ APRInitializer::APRInitializer() :
103105

104106
APRInitializer::~APRInitializer()
105107
{
108+
#if LOG4CXX_ABI_VERSION <= 15
106109
isDestructed = true;
110+
#endif
107111
#if APR_HAS_THREADS
108112
std::lock_guard<std::mutex> lock(m_priv->mutex);
109113
apr_threadkey_private_delete(m_priv->tlsKey);

src/main/cpp/fileinputstream.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,8 @@
1919
#include <log4cxx/helpers/fileinputstream.h>
2020
#include <log4cxx/helpers/exception.h>
2121
#include <log4cxx/helpers/bytebuffer.h>
22+
#include <log4cxx/helpers/pool.h>
2223
#include <apr_file_io.h>
23-
#include <log4cxx/helpers/transcoder.h>
24-
#if !defined(LOG4CXX)
25-
#define LOG4CXX 1
26-
#endif
27-
#include <log4cxx/helpers/aprinitializer.h>
2824

2925
using namespace LOG4CXX_NS;
3026
using namespace LOG4CXX_NS::helpers;
@@ -82,7 +78,7 @@ FileInputStream::FileInputStream(const File& aFile) :
8278

8379
FileInputStream::~FileInputStream()
8480
{
85-
if (m_priv->fileptr != NULL && !APRInitializer::isDestructed)
81+
if (m_priv->fileptr)
8682
{
8783
apr_file_close(m_priv->fileptr);
8884
}

src/main/cpp/fileoutputstream.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,10 @@
1717

1818
#include <log4cxx/logstring.h>
1919
#include <log4cxx/helpers/fileoutputstream.h>
20+
#include <log4cxx/helpers/pool.h>
2021
#include <log4cxx/helpers/exception.h>
2122
#include <log4cxx/helpers/bytebuffer.h>
2223
#include <apr_file_io.h>
23-
#include <log4cxx/helpers/transcoder.h>
24-
#if !defined(LOG4CXX)
25-
#define LOG4CXX 1
26-
#endif
27-
#include <log4cxx/helpers/aprinitializer.h>
2824

2925
using namespace LOG4CXX_NS;
3026
using namespace LOG4CXX_NS::helpers;
@@ -81,15 +77,15 @@ apr_file_t* FileOutputStream::open(const LogString& filename,
8177

8278
FileOutputStream::~FileOutputStream()
8379
{
84-
if (m_priv->fileptr != NULL && !APRInitializer::isDestructed)
80+
if (m_priv->fileptr)
8581
{
8682
apr_file_close(m_priv->fileptr);
8783
}
8884
}
8985

9086
void FileOutputStream::close(Pool& /* p */)
9187
{
92-
if (m_priv->fileptr != NULL)
88+
if (m_priv->fileptr)
9389
{
9490
apr_status_t stat = apr_file_close(m_priv->fileptr);
9591

src/main/cpp/threadspecificdata.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#include <sstream>
3232
#include <algorithm>
3333
#include <thread>
34+
#include <mutex>
35+
#include <list>
3436

3537
using namespace LOG4CXX_NS;
3638
using namespace LOG4CXX_NS::helpers;

src/main/include/log4cxx/helpers/aprinitializer.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,32 @@
2323
#endif
2424

2525
#include <log4cxx/helpers/object.h>
26-
#include <list>
27-
#include <log4cxx/helpers/date.h>
2826
#include <log4cxx/helpers/widelife.h>
2927

3028
extern "C" {
3129
struct apr_threadkey_t;
3230
struct apr_pool_t;
3331
}
34-
35-
#include <mutex>
3632
#include <functional>
3733

3834
namespace LOG4CXX_NS
3935
{
4036
namespace helpers
4137
{
38+
#if LOG4CXX_ABI_VERSION <= 15
4239
class FileWatchdog;
40+
#endif
4341

4442
class APRInitializer
4543
{
4644
public:
4745
#if LOG4CXX_ABI_VERSION <= 15
4846
static log4cxx_time_t initialize();
47+
static bool isDestructed;
4948
#endif
5049
static apr_pool_t* getRootPool();
5150
static log4cxx_time_t getStartTime();
5251
static apr_threadkey_t* getTlsKey();
53-
static bool isDestructed;
5452

5553
#if LOG4CXX_ABI_VERSION <= 15
5654
/**

src/main/include/log4cxx/helpers/fileinputstream.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
#include <log4cxx/helpers/inputstream.h>
2222
#include <log4cxx/file.h>
23-
#include <log4cxx/helpers/pool.h>
2423
#include <memory>
2524

2625
namespace LOG4CXX_NS
@@ -81,9 +80,10 @@ class LOG4CXX_EXPORT FileInputStream : public InputStream
8180

8281
private:
8382

84-
FileInputStream(const FileInputStream&);
83+
FileInputStream(const FileInputStream&) = delete;
84+
FileInputStream(FileInputStream&&) = delete;
8585

86-
FileInputStream& operator=(const FileInputStream&);
86+
FileInputStream& operator=(const FileInputStream&) = delete;
8787
void open(const LogString&);
8888

8989
};

src/main/include/log4cxx/helpers/fileoutputstream.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
#include <log4cxx/helpers/outputstream.h>
2222
#include <log4cxx/file.h>
23-
#include <log4cxx/helpers/pool.h>
2423

2524

2625
namespace LOG4CXX_NS
@@ -55,8 +54,9 @@ class LOG4CXX_EXPORT FileOutputStream : public OutputStream
5554
apr_file_t* getFilePtr() const;
5655

5756
private:
58-
FileOutputStream(const FileOutputStream&);
59-
FileOutputStream& operator=(const FileOutputStream&);
57+
FileOutputStream(const FileOutputStream&) = delete;
58+
FileOutputStream(FileOutputStream&&) = delete;
59+
FileOutputStream& operator=(const FileOutputStream&) = delete;
6060
static apr_file_t* open(const LogString& fn, bool append,
6161
LOG4CXX_NS::helpers::Pool& p);
6262
};

0 commit comments

Comments
 (0)