summaryrefslogtreecommitdiff
path: root/core/fxcrt/fx_xml_parser.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-12-07 13:45:41 -0800
committerCommit bot <commit-bot@chromium.org>2016-12-07 13:45:41 -0800
commitcd5e12a9ea397b48056643a7b65126395eec3174 (patch)
treed1b6b0c0e1b8f8d996aa987e6386338bca5ba92b /core/fxcrt/fx_xml_parser.cpp
parent7cda31ac2f2884166f044937619478a6103198cf (diff)
downloadpdfium-cd5e12a9ea397b48056643a7b65126395eec3174.tar.xz
Catch stray Retains() and Releases() outside of RetainPtr<>.
The previous CLs made the code clean, so now we can mark more things private, and add friends as appropriate. Review-Url: https://codereview.chromium.org/2560783003
Diffstat (limited to 'core/fxcrt/fx_xml_parser.cpp')
-rw-r--r--core/fxcrt/fx_xml_parser.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/core/fxcrt/fx_xml_parser.cpp b/core/fxcrt/fx_xml_parser.cpp
index ab30926387..1b562c2083 100644
--- a/core/fxcrt/fx_xml_parser.cpp
+++ b/core/fxcrt/fx_xml_parser.cpp
@@ -70,8 +70,8 @@ bool g_FXCRT_XML_IsNameChar(uint8_t ch) {
class CXML_DataBufAcc : public IFX_BufferedReadStream {
public:
- CXML_DataBufAcc(const uint8_t* pBuffer, size_t size);
- ~CXML_DataBufAcc() override;
+ template <typename T, typename... Args>
+ friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args);
// IFX_BufferedReadStream
bool IsEOF() override;
@@ -83,6 +83,9 @@ class CXML_DataBufAcc : public IFX_BufferedReadStream {
FX_FILESIZE GetBlockOffset() override;
private:
+ CXML_DataBufAcc(const uint8_t* pBuffer, size_t size);
+ ~CXML_DataBufAcc() override;
+
const uint8_t* m_pBuffer;
size_t m_dwSize;
size_t m_dwCurPos;
@@ -130,9 +133,8 @@ FX_FILESIZE CXML_DataBufAcc::GetBlockOffset() {
class CXML_DataStmAcc : public IFX_BufferedReadStream {
public:
- explicit CXML_DataStmAcc(
- const CFX_RetainPtr<IFX_SeekableReadStream>& pFileRead);
- ~CXML_DataStmAcc() override;
+ template <typename T, typename... Args>
+ friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args);
// IFX_BufferedReadStream
bool IsEOF() override;
@@ -144,6 +146,10 @@ class CXML_DataStmAcc : public IFX_BufferedReadStream {
FX_FILESIZE GetBlockOffset() override;
private:
+ explicit CXML_DataStmAcc(
+ const CFX_RetainPtr<IFX_SeekableReadStream>& pFileRead);
+ ~CXML_DataStmAcc() override;
+
CFX_RetainPtr<IFX_SeekableReadStream> m_pFileRead;
uint8_t* m_pBuffer;
FX_FILESIZE m_nStart;
@@ -215,12 +221,12 @@ CXML_Parser::CXML_Parser()
CXML_Parser::~CXML_Parser() {}
bool CXML_Parser::Init(uint8_t* pBuffer, size_t size) {
- m_pDataAcc.Reset(new CXML_DataBufAcc(pBuffer, size));
+ m_pDataAcc = pdfium::MakeRetain<CXML_DataBufAcc>(pBuffer, size);
return Init();
}
bool CXML_Parser::Init(const CFX_RetainPtr<IFX_SeekableReadStream>& pFileRead) {
- m_pDataAcc.Reset(new CXML_DataStmAcc(pFileRead));
+ m_pDataAcc = pdfium::MakeRetain<CXML_DataStmAcc>(pFileRead);
return Init();
}