diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-07-22 11:11:27 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-07-23 11:22:59 +0200 |
commit | 4e512171c21a193027c35d19a5273507a2725596 (patch) | |
tree | e0c354208a355c22f0e0ba9639b10a1010b2a52f /idlc | |
parent | 58ddacdb4be78dd00e05a46459ed0bcbe7531632 (diff) |
no need to allocate these static vars on demand
the constructor can be laid out at compile/link time
Change-Id: I377a537e15199ae81394d76ac662576280a25c25
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119362
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'idlc')
-rw-r--r-- | idlc/source/idlcproduce.cxx | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/idlc/source/idlcproduce.cxx b/idlc/source/idlcproduce.cxx index 92e7887236d2..e5ea206f0ff8 100644 --- a/idlc/source/idlcproduce.cxx +++ b/idlc/source/idlcproduce.cxx @@ -39,7 +39,7 @@ using namespace ::osl; -static std::list< OString >* pCreatedDirectories = nullptr; +static std::list< OString > gaCreatedDirectories; static bool checkOutputPath(const OString& completeName) { @@ -79,11 +79,10 @@ static bool checkOutputPath(const OString& completeName) idlc()->getOptions()->getProgramName().getStr(), buffer.getStr()); return false; } - } else + } + else { - if ( !pCreatedDirectories ) - pCreatedDirectories = new std::list< OString >; - pCreatedDirectories->push_front(buffer.getStr()); + gaCreatedDirectories.push_front(buffer.getStr()); } } buffer.append(SEPARATOR); @@ -93,23 +92,20 @@ static bool checkOutputPath(const OString& completeName) static bool cleanPath() { - if ( pCreatedDirectories ) + for (auto const& createdDirectory : gaCreatedDirectories) { - for (auto const& createdDirectory : *pCreatedDirectories) - { //#ifdef SAL_UNX -// if (rmdir((char*)createdDirectory.getStr(), 0777) == -1) +// if (rmdir((char*)createdDirectory.getStr(), 0777) == -1) //#else - if (rmdir(createdDirectory.getStr()) == -1) + if (rmdir(createdDirectory.getStr()) == -1) //#endif - { - fprintf(stderr, "%s: cannot remove directory '%s'\n", - idlc()->getOptions()->getProgramName().getStr(), createdDirectory.getStr()); - return false; - } + { + fprintf(stderr, "%s: cannot remove directory '%s'\n", + idlc()->getOptions()->getProgramName().getStr(), createdDirectory.getStr()); + return false; } - delete pCreatedDirectories; } + gaCreatedDirectories.clear(); return true; } |