[poppler] poppler/Object.h

Carlos Garcia Campos carlosgc at kemper.freedesktop.org
Wed Oct 2 03:33:56 PDT 2013


 poppler/Object.h |    4 ++++
 1 file changed, 4 insertions(+)

New commits:
commit 45e0fe56985f34e695c99a2f6ec1ffe14e239b9e
Author: Adrian Perez de Castro <aperez at igalia.com>
Date:   Thu Sep 26 20:56:52 2013 +0300

    Implement Object::takeString() method
    
    Object::takeString() behaves like Object::getString(), but transfers
    ownership of the returned string to the caller. Also, it makes sure that
    calling Object::free() afterwards won't free the string that the Object
    is holding.

diff --git a/poppler/Object.h b/poppler/Object.h
index 1b12354..58125d5 100644
--- a/poppler/Object.h
+++ b/poppler/Object.h
@@ -199,6 +199,10 @@ public:
   double getNum() { OBJECT_3TYPES_CHECK(objInt, objInt64, objReal);
     return type == objInt ? (double)intg : type == objInt64 ? (double)int64g : real; }
   GooString *getString() { OBJECT_TYPE_CHECK(objString); return string; }
+  // After takeString() the only method that should be called for the object is free()
+  // because the object it's not expected to have a NULL string.
+  GooString *takeString() {
+    OBJECT_TYPE_CHECK(objString); GooString *s = string; string = NULL; return s; }
   char *getName() { OBJECT_TYPE_CHECK(objName); return name; }
   Array *getArray() { OBJECT_TYPE_CHECK(objArray); return array; }
   Dict *getDict() { OBJECT_TYPE_CHECK(objDict); return dict; }


More information about the poppler mailing list