diff options
author | Lei Zhang <thestig@chromium.org> | 2015-10-08 12:32:46 -0700 |
---|---|---|
committer | Lei Zhang <thestig@chromium.org> | 2015-10-08 12:32:46 -0700 |
commit | d1cb813d23df38a8e21df3314658995ded7c4b45 (patch) | |
tree | 121280512f7b23d2648b86f04840f5ecb4493226 /core/src/fxcodec/jbig2/JBig2_List.h | |
parent | 67fd5df1a378195ae3fb40c862a4e6e58731020a (diff) | |
download | pdfium-d1cb813d23df38a8e21df3314658995ded7c4b45.tar.xz |
Merge to XFA: Put CJBig2_SymbolDict's images in a CJBig2_List container.
Also mark it private.
TBR=tsepez@chromium.org
Review URL: https://codereview.chromium.org/1395613003 .
(cherry picked from commit 8793b4a071fad51a770b93838e0752505b020e43)
Review URL: https://codereview.chromium.org/1397853002 .
Diffstat (limited to 'core/src/fxcodec/jbig2/JBig2_List.h')
-rw-r--r-- | core/src/fxcodec/jbig2/JBig2_List.h | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/core/src/fxcodec/jbig2/JBig2_List.h b/core/src/fxcodec/jbig2/JBig2_List.h index e033eb23ea..ffdd22c3ca 100644 --- a/core/src/fxcodec/jbig2/JBig2_List.h +++ b/core/src/fxcodec/jbig2/JBig2_List.h @@ -4,11 +4,13 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef _JBIG2_LIST_H_ -#define _JBIG2_LIST_H_ +#ifndef CORE_SRC_FXCODEC_JBIG2_JBIG2_LIST_H_ +#define CORE_SRC_FXCODEC_JBIG2_JBIG2_LIST_H_ #include <vector> +// A poor man's ScopedVector for pointers of TYPE. +// Owns all the pointers contained within and deletes them on destruction. template <class TYPE> class CJBig2_List { public: @@ -18,23 +20,28 @@ class CJBig2_List { clear(); } + TYPE* get(size_t index) const { return m_vector[index]; } + TYPE* back() const { return m_vector.back(); } + size_t size() const { return m_vector.size(); } + + // Deletes all the pointers contained within. void clear() { for (size_t i = 0; i < m_vector.size(); ++i) delete m_vector[i]; m_vector.clear(); } + // Takes ownership of |pItem|. void push_back(TYPE* pItem) { m_vector.push_back(pItem); } - size_t size() const { return m_vector.size(); } - void resize(size_t count) { m_vector.resize(count); } - - TYPE* get(size_t index) { return m_vector[index]; } - - TYPE* back() { return m_vector.back(); } + void resize(size_t count) { + for (size_t i = count; i < size(); ++i) + delete m_vector[i]; + m_vector.resize(count); + } private: std::vector<TYPE*> m_vector; }; -#endif +#endif // CORE_SRC_FXCODEC_JBIG2_JBIG2_LIST_H_ |