[Libreoffice-commits] core.git: hwpfilter/source
Caolán McNamara
caolanm at redhat.com
Thu Nov 2 20:26:48 UTC 2017
hwpfilter/source/hwpfile.h | 7 ++++---
hwpfilter/source/hwpread.cxx | 13 ++++++-------
2 files changed, 10 insertions(+), 10 deletions(-)
New commits:
commit 9a236714e539c772cad7b56caf21dc12b79e77df
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Nov 2 13:24:41 2017 +0000
ofz#3858 use a single scratch buffer
Change-Id: Icdea835b89da2e7233e17893c759e411d659811c
Reviewed-on: https://gerrit.libreoffice.org/44213
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/hwpfilter/source/hwpfile.h b/hwpfilter/source/hwpfile.h
index bfa6da1b97e6..817173d24707 100644
--- a/hwpfilter/source/hwpfile.h
+++ b/hwpfilter/source/hwpfile.h
@@ -31,7 +31,7 @@
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
-
+#include <sal/types.h>
#include "hwplib.h"
#include "hfont.h"
#include "hstyle.h"
@@ -273,11 +273,12 @@ class DLLEXPORT HWPFile
int info_block_len;
int error_code;
OlePicture *oledata;
+ unsigned char scratch[SAL_MAX_UINT16];
private:
/* hwp 파일 이름 */
- int m_nCurrentPage;
- int m_nMaxSettedPage;
+ int m_nCurrentPage;
+ int m_nMaxSettedPage;
HIODev *hiodev;
// read hwp contents
HWPInfo _hwpInfo;
diff --git a/hwpfilter/source/hwpread.cxx b/hwpfilter/source/hwpread.cxx
index 33ff358e44fa..46f278574da9 100644
--- a/hwpfilter/source/hwpread.cxx
+++ b/hwpfilter/source/hwpread.cxx
@@ -370,9 +370,9 @@ bool Picture::Read(HWPFile & hwpf)
hwpf.Read2b(reserved, 2);
hwpf.Read2b(&dummy, 1);
- if (!(hh == dummy && CH_PICTURE == dummy)){
+ if (!(hh == dummy && CH_PICTURE == dummy)) {
return hwpf.SetState(HWP_InvalidFileFormat);
- }
+ }
hwpf.AddBox(this);
hwpf.Read4b(&follow_block_size, 1);
@@ -444,15 +444,14 @@ bool Picture::Read(HWPFile & hwpf)
//read potentially compressed data in blocks as its more
//likely large values are simply broken and we'll run out
//of data before we need to realloc
- unsigned char buffer[SAL_MAX_UINT16];
- for (size_t i = 0; i < follow_block_size; i+= SAL_N_ELEMENTS(buffer))
+ for (size_t i = 0; i < follow_block_size; i+= SAL_N_ELEMENTS(hwpf.scratch))
{
size_t nOldSize = follow.size();
- size_t nBlock = std::min(SAL_N_ELEMENTS(buffer), follow_block_size - nOldSize);
- size_t nReadBlock = hwpf.Read1b(buffer, nBlock);
+ size_t nBlock = std::min(SAL_N_ELEMENTS(hwpf.scratch), follow_block_size - nOldSize);
+ size_t nReadBlock = hwpf.Read1b(hwpf.scratch, nBlock);
if (nReadBlock)
{
- follow.insert(follow.end(), buffer, buffer + nReadBlock);
+ follow.insert(follow.end(), hwpf.scratch, hwpf.scratch + nReadBlock);
}
if (nBlock != nReadBlock)
break;
More information about the Libreoffice-commits
mailing list