diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-09-06 11:25:33 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-09-07 08:48:12 +0200 |
commit | cf67ffaacba130a0c572f26cbd14a7492d9b53b8 (patch) | |
tree | ac3d41e3001040b304e20964034b802b37abbe8b /hwpfilter | |
parent | fda27303cfb84ef182696787878dba06c4a129da (diff) |
loplugin:useuniqueptr in HWPFile
Change-Id: I0eb3f09b5ca82ce4810aafbb7d5d53f1faa00e3f
Reviewed-on: https://gerrit.libreoffice.org/60111
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'hwpfilter')
-rw-r--r-- | hwpfilter/source/drawing.h | 4 | ||||
-rw-r--r-- | hwpfilter/source/hwpfile.cxx | 16 | ||||
-rw-r--r-- | hwpfilter/source/hwpfile.h | 2 |
3 files changed, 8 insertions, 14 deletions
diff --git a/hwpfilter/source/drawing.h b/hwpfilter/source/drawing.h index 806a48748bf7..5c2746da0099 100644 --- a/hwpfilter/source/drawing.h +++ b/hwpfilter/source/drawing.h @@ -626,12 +626,12 @@ static HWPPara *LoadParaList() return nullptr; HWPFile *hwpf = GetCurrentDoc(); - HIODev *hio = hwpf->SetIODevice(hmem); + std::unique_ptr<HIODev> hio = hwpf->SetIODevice(std::unique_ptr<HIODev>(hmem)); std::vector< HWPPara* > plist; hwpf->ReadParaList(plist); - hwpf->SetIODevice(hio); + hwpf->SetIODevice(std::move(hio)); return plist.size()? plist.front() : nullptr; } diff --git a/hwpfilter/source/hwpfile.cxx b/hwpfilter/source/hwpfile.cxx index a61b3e08921b..b1a4760d7644 100644 --- a/hwpfilter/source/hwpfile.cxx +++ b/hwpfilter/source/hwpfile.cxx @@ -94,17 +94,14 @@ int detect_hwp_version(const char *str) int HWPFile::Open(std::unique_ptr<HStream> stream) { - HStreamIODev *hstreamio = new HStreamIODev(std::move(stream)); + std::unique_ptr<HStreamIODev> hstreamio(new HStreamIODev(std::move(stream))); if (!hstreamio->open()) { - delete hstreamio; - return SetState(HWP_EMPTY_FILE); } - HIODev *pPrev = SetIODevice(hstreamio); - delete pPrev; + SetIODevice(std::move(hstreamio)); char idstr[HWPIDLen]; @@ -185,13 +182,10 @@ void HWPFile::SetCompressed(bool flag) } -HIODev *HWPFile::SetIODevice(HIODev * new_hiodev) +std::unique_ptr<HIODev> HWPFile::SetIODevice(std::unique_ptr<HIODev> new_hiodev) { - HIODev *old_hiodev = hiodev.release(); - - hiodev.reset( new_hiodev ); - - return old_hiodev; + std::swap(hiodev, new_hiodev); + return new_hiodev; } diff --git a/hwpfilter/source/hwpfile.h b/hwpfilter/source/hwpfile.h index 36655105a9f5..88e2151a5c9a 100644 --- a/hwpfilter/source/hwpfile.h +++ b/hwpfilter/source/hwpfile.h @@ -165,7 +165,7 @@ class DLLEXPORT HWPFile /** * Sets current HIODev */ - HIODev *SetIODevice( HIODev *hiodev ); + std::unique_ptr<HIODev> SetIODevice( std::unique_ptr<HIODev> hiodev ); /** * Reads all information of hwp file from stream |