[Libreoffice-commits] core.git: 2 commits - filter/source shell/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Oct 1 06:16:49 UTC 2018
filter/source/graphicfilter/ipcx/ipcx.cxx | 19 ++++++------
shell/source/tools/lngconvex/lngconvex.cxx | 43 +++++------------------------
2 files changed, 17 insertions(+), 45 deletions(-)
New commits:
commit c490bfac65ae2a95eddcf027c1b402aa2a199522
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Sep 27 10:33:59 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon Oct 1 08:16:35 2018 +0200
loplugin:useuniqueptr in shell::Substitutor
Change-Id: Iee1be29bb4f6a90ccc38d2da8372046350ada438
Reviewed-on: https://gerrit.libreoffice.org/61111
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/shell/source/tools/lngconvex/lngconvex.cxx b/shell/source/tools/lngconvex/lngconvex.cxx
index 85f36ae8e28e..67068980834e 100644
--- a/shell/source/tools/lngconvex/lngconvex.cxx
+++ b/shell/source/tools/lngconvex/lngconvex.cxx
@@ -199,7 +199,7 @@ class Substitutor
{
private:
typedef std::map<std::string, std::string> replacement_table_t;
- typedef std::map<std::string, replacement_table_t*> iso_lang_replacement_table_t;
+ typedef std::map<std::string, replacement_table_t> iso_lang_replacement_table_t;
public:
typedef iso_lang_replacement_table_t::iterator iterator;
@@ -215,17 +215,6 @@ public:
Substitutor() {};
- ~Substitutor()
- {
- iso_lang_replacement_table_t::iterator iter_end = iso_lang_replacement_table_.end();
- iso_lang_replacement_table_t::iterator iter = iso_lang_replacement_table_.begin();
-
- for( /* no init */; iter != iter_end; ++iter)
- delete iter->second;
-
- iso_lang_replacement_table_.clear();
- }
-
void set_language(const iso_lang_identifier& iso_lang)
{
active_iso_lang_ = iso_lang;
@@ -235,42 +224,26 @@ public:
//its substitute else leave it unchanged
void substitute(std::string& Text)
{
- replacement_table_t* prt = get_replacement_table(active_iso_lang_.make_std_string());
- OSL_ASSERT(prt);
- replacement_table_t::iterator iter = prt->find(Text);
- if (iter != prt->end())
+ replacement_table_t& prt = get_replacement_table(active_iso_lang_.make_std_string());
+ replacement_table_t::iterator iter = prt.find(Text);
+ if (iter != prt.end())
Text = iter->second;
}
void add_substitution(
const std::string& Placeholder, const std::string& Substitute)
{
- replacement_table_t* prt = get_replacement_table(active_iso_lang_.make_std_string());
- OSL_ASSERT(prt);
- prt->insert(std::make_pair(Placeholder, Substitute));
+ replacement_table_t& prt = get_replacement_table(active_iso_lang_.make_std_string());
+ prt.insert(std::make_pair(Placeholder, Substitute));
}
private:
// Return the replacement table for the iso lang id
// create a new one if not already present
- replacement_table_t* get_replacement_table(const std::string& iso_lang)
+ replacement_table_t& get_replacement_table(const std::string& iso_lang)
{
- iso_lang_replacement_table_t::iterator iter =
- iso_lang_replacement_table_.find(iso_lang);
-
- replacement_table_t* prt = nullptr;
-
- if (iso_lang_replacement_table_.end() == iter)
- {
- prt = new replacement_table_t;
- iso_lang_replacement_table_.insert(std::make_pair(iso_lang, prt));
- }
- else
- {
- prt = iter->second;
- }
- return prt;
+ return iso_lang_replacement_table_[iso_lang];
}
private:
commit 93edc2cf42c84025740e6fa779edd6e2b2e6a5c8
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Sep 27 10:33:43 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon Oct 1 08:16:26 2018 +0200
loplugin:useuniqueptr in PCXReader::ImplReadBody
Change-Id: I8aa249fbd5fd05fb9b5ca0dd1cddf3e0111cf201
Reviewed-on: https://gerrit.libreoffice.org/61110
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/filter/source/graphicfilter/ipcx/ipcx.cxx b/filter/source/graphicfilter/ipcx/ipcx.cxx
index 3a4e8a64b73f..f18f1747be9f 100644
--- a/filter/source/graphicfilter/ipcx/ipcx.cxx
+++ b/filter/source/graphicfilter/ipcx/ipcx.cxx
@@ -206,13 +206,14 @@ void PCXReader::ImplReadHeader()
void PCXReader::ImplReadBody()
{
- sal_uInt8 *pPlane[ 4 ], * pDest;
+ std::unique_ptr<sal_uInt8[]> pPlane[ 4 ];
+ sal_uInt8 * pDest;
sal_uLong i, nx, ny, np, nCount, nPercent;
sal_uLong nLastPercent = 0;
sal_uInt8 nDat = 0, nCol = 0;
for( np = 0; np < nPlanes; np++ )
- pPlane[ np ] = new sal_uInt8[ nBytesPerPlaneLin ];
+ pPlane[ np ].reset(new sal_uInt8[ nBytesPerPlaneLin ]);
nCount = 0;
for ( ny = 0; ny < nHeight; ny++ )
@@ -230,10 +231,10 @@ void PCXReader::ImplReadBody()
for ( np = 0; np < nPlanes; np++)
{
if ( nEncoding == 0)
- m_rPCX.ReadBytes( static_cast<void *>(pPlane[ np ]), nBytesPerPlaneLin );
+ m_rPCX.ReadBytes( static_cast<void *>(pPlane[ np ].get()), nBytesPerPlaneLin );
else
{
- pDest = pPlane[ np ];
+ pDest = pPlane[ np ].get();
nx = nBytesPerPlaneLin;
while ( nCount > 0 && nx > 0)
{
@@ -277,10 +278,10 @@ void PCXReader::ImplReadBody()
}
}
}
- sal_uInt8 *pSource1 = pPlane[ 0 ];
- sal_uInt8 *pSource2 = pPlane[ 1 ];
- sal_uInt8 *pSource3 = pPlane[ 2 ];
- sal_uInt8 *pSource4 = pPlane[ 3 ];
+ sal_uInt8 *pSource1 = pPlane[ 0 ].get();
+ sal_uInt8 *pSource2 = pPlane[ 1 ].get();
+ sal_uInt8 *pSource3 = pPlane[ 2 ].get();
+ sal_uInt8 *pSource4 = pPlane[ 3 ].get();
switch ( nBitsPerPlanePix + ( nPlanes << 8 ) )
{
// 2 colors
@@ -375,8 +376,6 @@ void PCXReader::ImplReadBody()
break;
}
}
- for ( np = 0; np < nPlanes; np++ )
- delete[] pPlane[ np ];
}
void PCXReader::ImplReadPalette( sal_uLong nCol )
More information about the Libreoffice-commits
mailing list