diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2009-07-24 20:39:55 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2009-07-24 20:39:55 (GMT) |
commit | b7c29570b9f6fecb6f042532f81e100a1f9b99a9 (patch) | |
tree | 4f2c158af3df6cdf9f7fd1db8ddceb30dbdd2bba /doc/src/snippets/code | |
parent | dffbcfb0adcad91f959a47edfdb5dd623c803306 (diff) | |
download | Qt-b7c29570b9f6fecb6f042532f81e100a1f9b99a9.zip Qt-b7c29570b9f6fecb6f042532f81e100a1f9b99a9.tar.gz Qt-b7c29570b9f6fecb6f042532f81e100a1f9b99a9.tar.bz2 |
Implement a new custom deleter implementation for QSharedPointer
Instead of using a template class derived from
QtSharedPointer::ExternalRefCountData, use a non-template class that
has a function pointer. This avoids generating a virtual table for
each QSharedPointer type and custom deleter.
The trick here is that we don't "new" the d pointer anymore, but we
simply allocate memory (via ::operator new, so it may throw an
exception), then we use the placement new to initialise the
non-template d-pointer and the template deleter sub-objects. Then we
store the pointer to a regular function which will execute the user's
custom deleter.
I also added operator delete() to the class to make sure no smarty
compiler decides to delete the d-pointer with a fixed size (I don't
think that happens, but just to be on the safe side).
Diffstat (limited to 'doc/src/snippets/code')
0 files changed, 0 insertions, 0 deletions