[Libreoffice-commits] core.git: hwpfilter/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Oct 23 10:02:26 UTC 2018
hwpfilter/source/drawing.h | 34 ++++++++++++++++++++--------------
1 file changed, 20 insertions(+), 14 deletions(-)
New commits:
commit 55f0b65b0568b8a8b1d823578eea1cbf633f4134
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Oct 23 09:27:51 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Oct 23 12:02:05 2018 +0200
loplugin:useuniqueptr in LoadDrawingObject
Change-Id: I6d6204128f40a87bc05987fa1ce724cf1d95aac1
Reviewed-on: https://gerrit.libreoffice.org/62220
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/hwpfilter/source/drawing.h b/hwpfilter/source/drawing.h
index 975dfaa0e8be..78c1240cdca1 100644
--- a/hwpfilter/source/drawing.h
+++ b/hwpfilter/source/drawing.h
@@ -316,17 +316,17 @@ static bool LoadCommonHeader(HWPDrawingObject * hdo, unsigned short * link_info)
return hmem->skipBlock(size - common_size ) != 0;
}
-static HWPDrawingObject *LoadDrawingObject(void)
+static std::unique_ptr<HWPDrawingObject> LoadDrawingObject(void)
{
- HWPDrawingObject *hdo, *head, *prev;
+ HWPDrawingObject *prev = nullptr;
+ std::unique_ptr<HWPDrawingObject> hdo, head;
unsigned short link_info;
- head = prev = nullptr;
do
{
- hdo = new HWPDrawingObject;
- if (!LoadCommonHeader(hdo, &link_info))
+ hdo.reset(new HWPDrawingObject);
+ if (!LoadCommonHeader(hdo.get(), &link_info))
{
goto error;
}
@@ -340,7 +340,7 @@ static HWPDrawingObject *LoadDrawingObject(void)
}
else
{
- switch (int res = HWPDOFunc(hdo, OBJFUNC_LOAD, nullptr, 0))
+ switch (int res = HWPDOFunc(hdo.get(), OBJFUNC_LOAD, nullptr, 0))
{
case OBJRET_FILE_ERROR:
goto error;
@@ -355,22 +355,28 @@ static HWPDrawingObject *LoadDrawingObject(void)
}
if (link_info & HDOFILE_HAS_CHILD)
{
- hdo->child.reset( LoadDrawingObject() );
+ hdo->child = LoadDrawingObject();
if (hdo->child == nullptr)
{
goto error;
}
}
if (prev == nullptr)
- head = hdo;
+ {
+ prev = hdo.get();
+ head = std::move(hdo);
+ }
else
- prev->next.reset( hdo );
- prev = hdo;
+ {
+ prev = hdo.get();
+ prev->next = std::move( hdo );
+ }
}
while (link_info & HDOFILE_HAS_NEXT);
return head;
- error:
+
+error:
// drawing object can be list.
// hdo = current item, head = list;
@@ -378,8 +384,8 @@ static HWPDrawingObject *LoadDrawingObject(void)
{
hdo->type = HWPDO_RECT;
}
- HWPDOFunc(hdo, OBJFUNC_FREE, nullptr, 0);
- delete hdo;
+ HWPDOFunc(hdo.get(), OBJFUNC_FREE, nullptr, 0);
+ hdo.reset();
if( prev )
{
@@ -417,7 +423,7 @@ static bool LoadDrawingObjectBlock(Picture * pic)
!hmem->skipBlock(size - HDOFILE_HEADER_SIZE))
return false;
- pic->picinfo.picdraw.hdo = LoadDrawingObject();
+ pic->picinfo.picdraw.hdo = LoadDrawingObject().release();
if (pic->picinfo.picdraw.hdo == nullptr)
return false;
return true;
More information about the Libreoffice-commits
mailing list