[Qt-interest] Replace Qt Allocator

Srdjan Todorovic todorovic.s at googlemail.com
Wed Sep 16 17:08:14 CEST 2009


Hi,

On 16/09/2009, Dan White <ygor at comcast.net> wrote:

> This is dangerously bad
> Reference: <http://www.devx.com/tips/Tip/12491>
>
> "Avoid Using malloc() and free() in C++
> The use of malloc() and free() functions in a C++ file is not recommended
> and is even dangerous:
> 1. malloc() requires the exact number of bytes as an argument whereas new
> calculates the size of the allocated object automatically. By using new,
> silly mistakes such as the following are avoided:

void SomeClass::foo()
{
   int blah = 0;
   int *zot = &blah;

   delete zot;    // BORK ?
}

Does that make delete dangerous and we should not use it? ;-)

Srdjan  (playing Devil's advocate for a moment)



More information about the Qt-interest-old mailing list