Sharing my progress (EteSync sync backend for Akonadi, GSoC '20)

Daniel Vrátil dvratil at kde.org
Tue Jun 9 14:19:50 BST 2020


On Tuesday, 9 June 2020 14:38:51 CEST Tom Hacohen wrote:
> On 09/06/2020 10:47, Daniel Vrátil wrote:
> > qPrintable(s) is just a macro that calls s.toLatin1().constData() here (so
> > basically convertintg QString to const char*, but the ownership of the
> > data
> > pointer to by the const char* remains in the QString (or rather the
> > QByteArray temporary created by QString::toLatin1()). Anyway, this way
> > the memory is only copied during the QString->QByteArray conversion, but
> > remains managed by the QString/QByteArray, so there are no memory leaks.
> 
> What about utf8 usernames and passwords? Would those be supported, or is
> there an equivalent call to do utf8 conversion?

Good point. If the C API supports it, then one should use qUtf8Printable 
instead of qPrintable.

> 
> > Same then goes with the returned EteSyncCollectionInfo*, EteSyncSyncEntry*
> > etc. pointers which you mostly forget to free: for this I would suggest
> > the
> > adaptor should never return a raw pointer unless the Etesync library
> > remains an owner of it, and wrap all pointers that you are supposed to
> > free yourself in std::unique_ptr so that you don't need to concern
> > yourself with deleting them manually.
> 
> EteSyncCollectionInfo and the likes have their own "destroy" functions,
> they shouldn't be freed directly with "free".

A customized std::unique_ptr should then be used, then. You can provide a 
custom destroy function to the std::unique_ptr, replacing the default 
"delete".

> 
> --
> Tom


-- 
Daniel Vrátil
www.dvratil.cz | dvratil at kde.org
IRC: dvratil on Freenode (#kde, #kontact, #akonadi, #fedora-kde)

GPG Key: 0x4D69557AECB13683
Fingerprint: 0ABD FA55 A4E6 BEA9 9A83 EA97 4D69 557A ECB1 3683
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20200609/d6b40488/attachment.sig>


More information about the kde-pim mailing list