Kaydet (Commit) 96c85e7d authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in hwpfilter

Change-Id: Id276015425ea7de3cf55b9ef21b4e7ce54c2ce47
üst 61bfcf16
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#define INCLUDED_HWPFILTER_SOURCE_DRAWDEF_H #define INCLUDED_HWPFILTER_SOURCE_DRAWDEF_H
#include "hwplib.h" #include "hwplib.h"
#include <memory>
class HWPPara; class HWPPara;
...@@ -228,11 +229,11 @@ struct HWPDrawingObject ...@@ -228,11 +229,11 @@ struct HWPDrawingObject
HWPDOArc arc; HWPDOArc arc;
} }
u; u;
struct HWPDrawingObject *next; std::unique_ptr<struct HWPDrawingObject> next;
/** /**
* This exists for container object * This exists for container object
*/ */
struct HWPDrawingObject *child; std::unique_ptr<struct HWPDrawingObject> child;
int index; int index;
HWPDrawingObject(); HWPDrawingObject();
~HWPDrawingObject(); ~HWPDrawingObject();
......
...@@ -355,7 +355,7 @@ static HWPDrawingObject *LoadDrawingObject(void) ...@@ -355,7 +355,7 @@ static HWPDrawingObject *LoadDrawingObject(void)
} }
if (link_info & HDOFILE_HAS_CHILD) if (link_info & HDOFILE_HAS_CHILD)
{ {
hdo->child = LoadDrawingObject(); hdo->child.reset( LoadDrawingObject() );
if (hdo->child == nullptr) if (hdo->child == nullptr)
{ {
goto error; goto error;
...@@ -364,7 +364,7 @@ static HWPDrawingObject *LoadDrawingObject(void) ...@@ -364,7 +364,7 @@ static HWPDrawingObject *LoadDrawingObject(void)
if (prev == nullptr) if (prev == nullptr)
head = hdo; head = hdo;
else else
prev->next = hdo; prev->next.reset( hdo );
prev = hdo; prev = hdo;
} }
while (link_info & HDOFILE_HAS_NEXT); while (link_info & HDOFILE_HAS_NEXT);
...@@ -682,12 +682,6 @@ HWPDrawingObject::HWPDrawingObject() ...@@ -682,12 +682,6 @@ HWPDrawingObject::HWPDrawingObject()
HWPDrawingObject::~HWPDrawingObject() HWPDrawingObject::~HWPDrawingObject()
{ {
if (child)
delete child;
if (next)
delete next;
if (property.pPara) if (property.pPara)
FreeParaList(property.pPara); FreeParaList(property.pPara);
......
...@@ -61,8 +61,8 @@ HWPFile::HWPFile() ...@@ -61,8 +61,8 @@ HWPFile::HWPFile()
HWPFile::~HWPFile() HWPFile::~HWPFile()
{ {
delete oledata; oledata.reset();
delete hiodev; hiodev.reset();
} }
int HWPFile::ReadHwpFile(HStream * stream) int HWPFile::ReadHwpFile(HStream * stream)
...@@ -185,9 +185,9 @@ void HWPFile::SetCompressed(bool flag) ...@@ -185,9 +185,9 @@ void HWPFile::SetCompressed(bool flag)
HIODev *HWPFile::SetIODevice(HIODev * new_hiodev) 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; return old_hiodev;
} }
...@@ -316,8 +316,7 @@ void HWPFile::TagsRead() ...@@ -316,8 +316,7 @@ void HWPFile::TagsRead()
} }
break; break;
case FILETAG_OLE_OBJECT: case FILETAG_OLE_OBJECT:
delete oledata; oledata.reset( new OlePicture(size) );
oledata = new OlePicture(size);
oledata->Read(*this); oledata->Read(*this);
break; break;
case FILETAG_HYPERTEXT: case FILETAG_HYPERTEXT:
......
...@@ -273,7 +273,7 @@ class DLLEXPORT HWPFile ...@@ -273,7 +273,7 @@ class DLLEXPORT HWPFile
unsigned char linenumber; unsigned char linenumber;
int info_block_len; int info_block_len;
int error_code; int error_code;
OlePicture *oledata; std::unique_ptr<OlePicture> oledata;
unsigned char scratch[SAL_MAX_UINT16]; unsigned char scratch[SAL_MAX_UINT16];
int readdepth; int readdepth;
...@@ -281,7 +281,7 @@ class DLLEXPORT HWPFile ...@@ -281,7 +281,7 @@ class DLLEXPORT HWPFile
/* hwp 파일 이름 */ /* hwp 파일 이름 */
int m_nCurrentPage; int m_nCurrentPage;
int m_nMaxSettedPage; int m_nMaxSettedPage;
HIODev *hiodev; std::unique_ptr<HIODev> hiodev;
// read hwp contents // read hwp contents
HWPInfo _hwpInfo; HWPInfo _hwpInfo;
HWPFont _hwpFont; HWPFont _hwpFont;
......
...@@ -427,12 +427,12 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo ) ...@@ -427,12 +427,12 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo )
while( hdo ) while( hdo )
{ {
if( hdo->child ) if( hdo->child )
makeDrawMiscStyle( hdo->child ); makeDrawMiscStyle( hdo->child.get() );
HWPDOProperty *prop = &hdo->property; HWPDOProperty *prop = &hdo->property;
if( hdo->type == HWPDO_CONTAINER ) if( hdo->type == HWPDO_CONTAINER )
{ {
hdo = hdo->next; hdo = hdo->next.get();
continue; continue;
} }
...@@ -694,7 +694,7 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo ) ...@@ -694,7 +694,7 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo )
rendEl( "draw:hatch"); rendEl( "draw:hatch");
} }
} }
hdo = hdo->next; hdo = hdo->next.get();
} }
} }
...@@ -2205,9 +2205,9 @@ void HwpReader::makeDrawStyle( HWPDrawingObject * hdo, FBoxStyle * fstyle) ...@@ -2205,9 +2205,9 @@ void HwpReader::makeDrawStyle( HWPDrawingObject * hdo, FBoxStyle * fstyle)
if( hdo->type == 0 ) 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) ...@@ -4016,7 +4016,7 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox)
{ {
rstartEl("draw:g", mxList.get()); rstartEl("draw:g", mxList.get());
mxList->clear(); mxList->clear();
makePictureDRAW(drawobj->child, hbox); makePictureDRAW(drawobj->child.get(), hbox);
rendEl("draw:g"); rendEl("draw:g");
} }
else else
...@@ -4574,7 +4574,7 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox) ...@@ -4574,7 +4574,7 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox)
} }
} }
mxList->clear(); mxList->clear();
drawobj = drawobj->next; drawobj = drawobj->next.get();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment