[Interest] Internal Qt bug or incorrect user API call?
bhood2 at comcast.net
Thu Aug 28 13:31:19 CEST 2014
On 8/8/2014 5:46 PM, T Stutts wrote:
> This is a copy of my post
> at http://qt-project.org/forums/viewthread/46102/and I am taking the replied
> suggestion of asking the mailing list. I hope the copy/pasted markup is okay.
> What does this line
> <https://qt.gitorious.org/qt/digia-qt/source/705b0f958a6071341b10cbd51917e1378356491b:src/corelib/tools/qvarlengtharray.h#L194this> /[qt.gitorious.org
> <http://qt.gitorious.org>]/ line do?
> I am referring to the line
> new (ptr+(s++)) T(*abuf++);
> It looks to me like an explicit memory leak (see new()
> <http://en.cppreference.com/w/cpp/language/new> /[en.cppreference.com
> It expressly allocates dynamic memory and does not store the pointer
> anywhere, unless Qt has its own allocation implementation
> (ie set_new_handler()
I've not looked at the code, but that does seem to be a non-standard use of
the keyword. So it could be a custom "new" that Qt uses, or -- I've never
seen it used before -- it might be the "placement" form of the C++ new
void* operator new (std::size_t size, void* ptr) throw();
Simply returns ptr(no storage is allocated).
Notice though that, if the function is called by a /new-expression/, the
proper initialization will be performed (for class objects, this includes
calling its default constructor).
Just guessing. :)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Interest