summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-01-16 14:02:57 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-01-19 08:58:46 +0200
commit96c85e7d107ad0d79295349f01cd8578ce7daeba (patch)
treec205fda67414559b325ab94b8e8dfff753d9ee4c
parent61bfcf16dc6e4cedcd82b51a646b89909f035f2d (diff)
loplugin:useuniqueptr in hwpfilter
Change-Id: Id276015425ea7de3cf55b9ef21b4e7ce54c2ce47
-rw-r--r--hwpfilter/source/drawdef.h5
-rw-r--r--hwpfilter/source/drawing.h10
-rw-r--r--hwpfilter/source/hwpfile.cxx11
-rw-r--r--hwpfilter/source/hwpfile.h4
-rw-r--r--hwpfilter/source/hwpreader.cxx14
5 files changed, 19 insertions, 25 deletions
diff --git a/hwpfilter/source/drawdef.h b/hwpfilter/source/drawdef.h
index f502d1a333fd..00296d8d1704 100644
--- a/hwpfilter/source/drawdef.h
+++ b/hwpfilter/source/drawdef.h
@@ -21,6 +21,7 @@
#define INCLUDED_HWPFILTER_SOURCE_DRAWDEF_H
#include "hwplib.h"
+#include <memory>
class HWPPara;
@@ -228,11 +229,11 @@ struct HWPDrawingObject
HWPDOArc arc;
}
u;
- struct HWPDrawingObject *next;
+ std::unique_ptr<struct HWPDrawingObject> next;
/**
* This exists for container object
*/
- struct HWPDrawingObject *child;
+ std::unique_ptr<struct HWPDrawingObject> child;
int index;
HWPDrawingObject();
~HWPDrawingObject();
diff --git a/hwpfilter/source/drawing.h b/hwpfilter/source/drawing.h
index 64abf44a67d7..806a48748bf7 100644
--- a/hwpfilter/source/drawing.h
+++ b/hwpfilter/source/drawing.h
@@ -355,7 +355,7 @@ static HWPDrawingObject *LoadDrawingObject(void)
}
if (link_info & HDOFILE_HAS_CHILD)
{
- hdo->child = LoadDrawingObject();
+ hdo->child.reset( LoadDrawingObject() );
if (hdo->child == nullptr)
{
goto error;
@@ -364,7 +364,7 @@ static HWPDrawingObject *LoadDrawingObject(void)
if (prev == nullptr)
head = hdo;
else
- prev->next = hdo;
+ prev->next.reset( hdo );
prev = hdo;
}
while (link_info & HDOFILE_HAS_NEXT);
@@ -682,12 +682,6 @@ HWPDrawingObject::HWPDrawingObject()
HWPDrawingObject::~HWPDrawingObject()
{
- if (child)
- delete child;
-
- if (next)
- delete next;
-
if (property.pPara)
FreeParaList(property.pPara);
diff --git a/hwpfilter/source/hwpfile.cxx b/hwpfilter/source/hwpfile.cxx
index 128be0caa7af..13d1416ece4b 100644
--- a/hwpfilter/source/hwpfile.cxx
+++ b/hwpfilter/source/hwpfile.cxx
@@ -61,8 +61,8 @@ HWPFile::HWPFile()
HWPFile::~HWPFile()
{
- delete oledata;
- delete hiodev;
+ oledata.reset();
+ hiodev.reset();
}
int HWPFile::ReadHwpFile(HStream * stream)
@@ -185,9 +185,9 @@ void HWPFile::SetCompressed(bool flag)
HIODev *HWPFile::SetIODevice(HIODev * new_hiodev)
{
- HIODev *old_hiodev = hiodev;
+ HIODev *old_hiodev = hiodev.release();
- hiodev = new_hiodev;
+ hiodev.reset( new_hiodev );
return old_hiodev;
}
@@ -316,8 +316,7 @@ void HWPFile::TagsRead()
}
break;
case FILETAG_OLE_OBJECT:
- delete oledata;
- oledata = new OlePicture(size);
+ oledata.reset( new OlePicture(size) );
oledata->Read(*this);
break;
case FILETAG_HYPERTEXT:
diff --git a/hwpfilter/source/hwpfile.h b/hwpfilter/source/hwpfile.h
index dc170226ea22..0f569d358257 100644
--- a/hwpfilter/source/hwpfile.h
+++ b/hwpfilter/source/hwpfile.h
@@ -273,7 +273,7 @@ class DLLEXPORT HWPFile
unsigned char linenumber;
int info_block_len;
int error_code;
- OlePicture *oledata;
+ std::unique_ptr<OlePicture> oledata;
unsigned char scratch[SAL_MAX_UINT16];
int readdepth;
@@ -281,7 +281,7 @@ class DLLEXPORT HWPFile
/* hwp 파일 이름 */
int m_nCurrentPage;
int m_nMaxSettedPage;
- HIODev *hiodev;
+ std::unique_ptr<HIODev> hiodev;
// read hwp contents
HWPInfo _hwpInfo;
HWPFont _hwpFont;
diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 87f782359bb4..f4b809f48a33 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -427,12 +427,12 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo )
while( hdo )
{
if( hdo->child )
- makeDrawMiscStyle( hdo->child );
+ makeDrawMiscStyle( hdo->child.get() );
HWPDOProperty *prop = &hdo->property;
if( hdo->type == HWPDO_CONTAINER )
{
- hdo = hdo->next;
+ hdo = hdo->next.get();
continue;
}
@@ -694,7 +694,7 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo )
rendEl( "draw:hatch");
}
}
- hdo = hdo->next;
+ hdo = hdo->next.get();
}
}
@@ -2205,9 +2205,9 @@ void HwpReader::makeDrawStyle( HWPDrawingObject * hdo, FBoxStyle * fstyle)
if( hdo->type == 0 )
{
- makeDrawStyle( hdo->child, fstyle );
+ makeDrawStyle( hdo->child.get(), fstyle );
}
- hdo = hdo->next;
+ hdo = hdo->next.get();
}
}
@@ -4016,7 +4016,7 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox)
{
rstartEl("draw:g", mxList.get());
mxList->clear();
- makePictureDRAW(drawobj->child, hbox);
+ makePictureDRAW(drawobj->child.get(), hbox);
rendEl("draw:g");
}
else
@@ -4574,7 +4574,7 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox)
}
}
mxList->clear();
- drawobj = drawobj->next;
+ drawobj = drawobj->next.get();
}
}