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/source/hwpfile.cxx | |
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/source/hwpfile.cxx')
-rw-r--r-- | hwpfilter/source/hwpfile.cxx | 16 |
1 files changed, 5 insertions, 11 deletions
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; } |