diff options
-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 |