[poppler] Object management helper class
Carlos Garcia Campos
carlosgc at gnome.org
Mon May 30 13:43:19 UTC 2016
Albert Astals Cid <aacid at kde.org> writes:
> Hi guys, related to the previous email about std::unique_ptr I think we would
> greatly benefit of a class that makes Object management easier.
>
> Again if you go and check https://bugs.freedesktop.org/attachment.cgi?
> id=124163 we're missing lots of free() and it's hard to prove we won't miss
> more.
>
> My suggestion is adding a class called UniqueObject (better name welcome)
> which will:
> * Call free on itself when it goes out of scope
> So we don't need to add .free() in every other if-chek-error-return
> * Call free on itself when you write on it
> So we can do
>
> dict->lookup("Decode", &obj1);
> if (obj1.isNull()) {
> dict->lookup("D", &obj1);
> }
>
> instead of
>
> dict->lookup("Decode", &obj1);
> if (obj1.isNull()) {
> obj1.free();
> dict->lookup("D", &obj1);
> }
>
> What do you think?
Why do we need a new class? Wouldn't it be enough to call free in the
Object destructor and init* methods?
> Cheers,
> Albert
> _______________________________________________
> poppler mailing list
> poppler at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/poppler
--
Carlos Garcia Campos
PGP key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x523E6462
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 180 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/poppler/attachments/20160530/6b71b8f9/attachment.sig>
More information about the poppler
mailing list