[poppler] poppler/Array.cc poppler/Array.h poppler/Object.h
Albert Astals Cid
aacid at kemper.freedesktop.org
Wed Mar 28 11:02:09 PDT 2012
poppler/Array.cc | 13 +++++++++++++
poppler/Array.h | 4 ++++
poppler/Object.h | 5 +++++
3 files changed, 22 insertions(+)
New commits:
commit ee0eaabe24019d2af226ef03e3f456787525e040
Author: Fabio D'Urso <fabiodurso at hotmail.it>
Date: Mon Mar 19 00:05:49 2012 +0100
Added Array::remove (and Object::arrayRemove)
diff --git a/poppler/Array.cc b/poppler/Array.cc
index e7ec4e7..cb22432 100644
--- a/poppler/Array.cc
+++ b/poppler/Array.cc
@@ -14,6 +14,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2005 Kristian Høgsberg <krh at redhat.com>
+// Copyright (C) 2012 Fabio D'Urso <fabiodurso at hotmail.it>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
@@ -64,6 +65,18 @@ void Array::add(Object *elem) {
++length;
}
+void Array::remove(int i) {
+ if (i < 0 || i >= length) {
+#ifdef DEBUG_MEM
+ abort();
+#else
+ return;
+#endif
+ }
+ --length;
+ memmove( elems + i, elems + i + 1, sizeof(elems[0]) * (length - i) );
+}
+
Object *Array::get(int i, Object *obj) {
if (i < 0 || i >= length) {
#ifdef DEBUG_MEM
diff --git a/poppler/Array.h b/poppler/Array.h
index a6aca26..666a409 100644
--- a/poppler/Array.h
+++ b/poppler/Array.h
@@ -14,6 +14,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2005 Kristian Høgsberg <krh at redhat.com>
+// Copyright (C) 2012 Fabio D'Urso <fabiodurso at hotmail.it>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
@@ -54,6 +55,9 @@ public:
// Add an element.
void add(Object *elem);
+ // Remove an element by position
+ void remove(int i);
+
// Accessors.
Object *get(int i, Object *obj);
Object *getNF(int i, Object *obj);
diff --git a/poppler/Object.h b/poppler/Object.h
index a67b403..c885d73 100644
--- a/poppler/Object.h
+++ b/poppler/Object.h
@@ -17,6 +17,7 @@
// Copyright (C) 2008 Kees Cook <kees at outflux.net>
// Copyright (C) 2008, 2010 Albert Astals Cid <aacid at kde.org>
// Copyright (C) 2009 Jakub Wilk <ubanus at users.sf.net>
+// Copyright (C) 2012 Fabio D'Urso <fabiodurso at hotmail.it>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
@@ -205,6 +206,7 @@ public:
// Array accessors.
int arrayGetLength();
void arrayAdd(Object *elem);
+ void arrayRemove(int i);
Object *arrayGet(int i, Object *obj);
Object *arrayGetNF(int i, Object *obj);
@@ -273,6 +275,9 @@ inline int Object::arrayGetLength()
inline void Object::arrayAdd(Object *elem)
{ OBJECT_TYPE_CHECK(objArray); array->add(elem); }
+inline void Object::arrayRemove(int i)
+ { OBJECT_TYPE_CHECK(objArray); array->remove(i); }
+
inline Object *Object::arrayGet(int i, Object *obj)
{ OBJECT_TYPE_CHECK(objArray); return array->get(i, obj); }
More information about the poppler
mailing list