summaryrefslogtreecommitdiff
path: root/hwpfilter/source/hbox.h
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-01-16 14:15:13 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-01-17 08:34:42 +0000
commit7a60e90ef05c84923f83882efc01c33fef1ed305 (patch)
tree4c49f1ab14fda2a79e0d8efdb731d4d6fe924eba /hwpfilter/source/hbox.h
parenta9367c1b39600d5a5e2d0067113f06ad59cc37a1 (diff)
new loplugin: useuniqueptr: helpcompiler..io
Change-Id: I6b394163c144e6b5540cb160abb613d56fe327de Reviewed-on: https://gerrit.libreoffice.org/33165 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'hwpfilter/source/hbox.h')
-rw-r--r--hwpfilter/source/hbox.h29
1 files changed, 14 insertions, 15 deletions
diff --git a/hwpfilter/source/hbox.h b/hwpfilter/source/hbox.h
index 3832c7617174..8d039ae49838 100644
--- a/hwpfilter/source/hbox.h
+++ b/hwpfilter/source/hbox.h
@@ -23,6 +23,7 @@
#include <sal/config.h>
#include <list>
+#include <memory>
#include <sal/types.h>
@@ -73,7 +74,7 @@ struct SkipData: public HBox
{
uint data_block_len;
hchar dummy;
- char *data_block;
+ std::unique_ptr<char[]> data_block;
explicit SkipData(hchar);
virtual ~SkipData() override;
@@ -385,27 +386,26 @@ struct TxtBox: public FBox
struct Columns
{
- int *data;
+ std::unique_ptr<int[]> data;
size_t nCount;
size_t nTotal;
Columns(){
nCount = 0;
nTotal = INIT_SIZE;
- data = new int[nTotal];
+ data.reset(new int[nTotal]);
}
- ~Columns(){ delete[] data; }
+ ~Columns() {}
void AddColumnsSize(){
- int *tmp = data;
if (nTotal + ADD_AMOUNT < nTotal) // overflow
{
throw ::std::bad_alloc();
}
- data = new int[nTotal + ADD_AMOUNT];
+ int* tmp = new int[nTotal + ADD_AMOUNT];
for (size_t i = 0 ; i < nTotal ; i++)
- data[i] = tmp[i];
+ tmp[i] = data[i];
nTotal += ADD_AMOUNT;
- delete[] tmp;
+ data.reset(tmp);
}
void insert(int pos){
@@ -446,27 +446,26 @@ struct Columns
struct Rows
{
- int *data;
+ std::unique_ptr<int[]> data;
size_t nCount;
size_t nTotal;
Rows(){
nCount = 0;
nTotal = INIT_SIZE;
- data = new int[nTotal];
+ data.reset( new int[nTotal] );
}
- ~Rows(){ delete[] data; }
+ ~Rows() {}
void AddRowsSize(){
- int *tmp = data;
if (nTotal + ADD_AMOUNT < nTotal) // overflow
{
throw ::std::bad_alloc();
}
- data = new int[nTotal + ADD_AMOUNT];
+ int* tmp = new int[nTotal + ADD_AMOUNT];
for (size_t i = 0 ; i < nTotal ; i++)
- data[i] = tmp[i];
+ tmp[i] = data[i];
nTotal += ADD_AMOUNT;
- delete[] tmp;
+ data.reset(tmp);
}
void insert(int pos){