From 4e512171c21a193027c35d19a5273507a2725596 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 22 Jul 2021 11:11:27 +0200 Subject: 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 --- idlc/source/idlcproduce.cxx | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'idlc') 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; } -- cgit