Mail Archives: djgpp/2000/09/11/04:00:34
djgpp AT delorie DOT com wrote:
>Can't you do it like this:
> char *x=new char[255];
> free(x);
>Will it work?
>I though it is the same meaning whether you use malloc or 'new', and the
>same meaning whether you free it or delete it. These should result in
>the same OS API, regardless of the language you use.
>I have been deleting a strdup() from long time. That all was a waste!!!
>
The point is, that you cannot be sure what delete will do. It
could simply call free, but there is no guarantee. If you are
using new to get your memory, free it with delete.
Otherwise you might (by accident) do something like this:
SomeClass* x = new SomeClass [n];
..
free (x);
This will definitely not do what you want.
--
Manni
"Life would be much easier if I had the source code."
- Raw text -