[PATCH] Adds "deep" copy constructor to Dict.

Julien Rebetez julien at fhtagn.net
Fri Oct 26 05:20:43 PDT 2007


---
 poppler/Dict.cc |   15 ++++++++++++++-
 poppler/Dict.h  |    1 +
 2 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/poppler/Dict.cc b/poppler/Dict.cc
index 0c74566..bc0d7b6 100644
--- a/poppler/Dict.cc
+++ b/poppler/Dict.cc
@@ -30,6 +30,18 @@ Dict::Dict(XRef *xrefA) {
   ref = 1;
 }
 
+Dict::Dict(Dict* dictA) {
+  xref = dictA->xref;
+  size = length = dictA->length;
+  ref = 1;
+
+  entries = (DictEntry *)gmallocn(size, sizeof(DictEntry));
+  for (int i=0; i<length; i++) {
+    entries[i].key = strdup(dictA->entries[i].key);
+    dictA->entries[i].val.copy(&entries[i].val);
+  }
+}
+
 Dict::~Dict() {
   int i;
 
@@ -89,7 +101,8 @@ void Dict::set(char *key, Object *val) {
   e = find (key);
   if (e) {
     e->val.free();
-    e->val = *val;
+    //e->val = *val;
+    val->copy(&e->val);
   } else {
     add (copyString(key), val);
   }
diff --git a/poppler/Dict.h b/poppler/Dict.h
index 0d1e6a1..badb6b5 100644
--- a/poppler/Dict.h
+++ b/poppler/Dict.h
@@ -29,6 +29,7 @@ public:
 
   // Constructor.
   Dict(XRef *xrefA);
+  Dict(Dict* dictA);
 
   // Destructor.
   ~Dict();
-- 
1.5.2.5


--------------030500050101040903030608
Content-Type: text/x-patch;
 name="0005-Annot-will-save-their-generated-appearance-in-their.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename*0="0005-Annot-will-save-their-generated-appearance-in-their.pat";
 filename*1="ch"



More information about the poppler mailing list