|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
|
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Dec 26, 9:01 pm, Andrew Wingorodov <m...@andr.ca> wrote:
> can i call delete for malloc() allocated memory? > > --www.andr.ru why do this? |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On Dec 26, 6:01pm, Andrew Wingorodov <m...@andr.ca> wrote:
> can i call delete for malloc() allocated memory? > > --www.andr.ru It will produce unpredictable results, often leading to program crash. Though, I don't know the reason, I have read this in Scott Maeyer's Effective C++ |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
<snip>
NO!!!!!!!!!! Never call delete on memory wich have been allocated by malloc . Never call free on memory wich have been allocated by new. new <->delete new[] <->delete[] malloc <->free |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
On Wed, 26 Dec 2007 05:23:06 -0800 (PST), Anuj <anujwadhva@gmail.com>
wrote in comp.lang.c++: > On Dec 26, 6:01pm, Andrew Wingorodov <m...@andr.ca> wrote: > > can i call delete for malloc() allocated memory? > > > > --www.andr.ru > > It will produce unpredictable results, often leading to program crash. No, it will cause undefined behavior, which is a term defined by the C++ language standard. That standard does not define the term "unpredictable results". > Though, I don't know the reason, I have read this in Scott Maeyer's > Effective C++ The reason is that it causes undefined behavior. You break the rules and you no longer have a C++ program. -- Jack Klein Home: http://JK-Technology.Com FAQs for comp.lang.c http://c-faq.com/ comp.lang.c++ http://www.parashift.com/c++-faq-lite/ alt.comp.lang.learn.c-c++ http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html |
|
![]() |
| Outils de la discussion | |
|
|