Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(445)

Unified Diff: core/src/fxcodec/jbig2/JBig2_List.h

Issue 1395613003: Put CJBig2_SymbolDict's images in a CJBig2_List container. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/src/fxcodec/jbig2/JBig2_Context.cpp ('k') | core/src/fxcodec/jbig2/JBig2_SddProc.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_
« no previous file with comments | « core/src/fxcodec/jbig2/JBig2_Context.cpp ('k') | core/src/fxcodec/jbig2/JBig2_SddProc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698