diff options
author | Adrian Perez de Castro <aperez@igalia.com> | 2013-09-26 20:56:52 +0300 |
---|---|---|
committer | Carlos Garcia Campos <carlosgc@gnome.org> | 2013-10-02 12:28:08 +0200 |
commit | 45e0fe56985f34e695c99a2f6ec1ffe14e239b9e (patch) | |
tree | 206a6d1003143a8cd98844f6f3c9b45798468ae3 | |
parent | d80eb4a34c218de34633ee2f1b9dfd65504a0ad9 (diff) |
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.
-rw-r--r-- | poppler/Object.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/poppler/Object.h b/poppler/Object.h index 1b123549..58125d5c 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; } |