| Index: core/src/fxcodec/jbig2/JBig2_List.h
|
| diff --git a/core/src/fxcodec/jbig2/JBig2_List.h b/core/src/fxcodec/jbig2/JBig2_List.h
|
| index e033eb23ea4d7b4a9d5ba674f382799f95bf3c75..ffdd22c3ca7bc0659ca2983fc235eae0d3f25fe1 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_
|
|
|