Mail Archives: djgpp/2001/05/03/11:15:10
Rafal Maj wrote:
>
> So both delete s; and delete[] s; are wrong ? I know that delete is C++
> style, but since char* has no destructor, I think that delete or delete[]
> will work for this type same as free(). Am I right ?
>
No - neither the C++ nor the C standard say that new and malloc()
allocate
memory the same way. So you can't use free() to free memory allocated by
new, nor can you use delete to free memory allocated by malloc().
In practice, many implementations of new and delete (including the ones
in
the GNU library) use malloc and free internally. But there's no
guarantee
this will stay that way, and it certianly isn't portable to make that
assumption.
--
Tim Van Holder - Falcon Software N.V.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
This message was posted using plain text. I do not endorse any
products or services that may be hyperlinked to this message.
- Raw text -