Click here to Skip to main content
16,013,465 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Win32 or MFC Pin
redneckCoder5-Feb-02 7:33
redneckCoder5-Feb-02 7:33 
GeneralRe: Win32 or MFC Pin
alex.barylski5-Feb-02 14:16
alex.barylski5-Feb-02 14:16 
GeneralCToolBar default position and destruction Pin
5-Feb-02 5:46
suss5-Feb-02 5:46 
GeneralAnother String Question Pin
Tom Wright5-Feb-02 4:33
Tom Wright5-Feb-02 4:33 
GeneralRe: Another String Question Pin
Jon Hulatt5-Feb-02 4:52
Jon Hulatt5-Feb-02 4:52 
GeneralRe: Another String Question Pin
Jamie Hale5-Feb-02 6:00
Jamie Hale5-Feb-02 6:00 
GeneralRe: Another String Question Pin
Nemanja Trifunovic5-Feb-02 6:14
Nemanja Trifunovic5-Feb-02 6:14 
GeneralRe: Another String Question Pin
Joaquín M López Muñoz5-Feb-02 6:25
Joaquín M López Muñoz5-Feb-02 6:25 
No, you don't. delete[] differs from delete because it calls destructors for all the objects in an array. For "built-in" type, you have no destructors and it does not make a difference.

IMHO it does make a difference. When allocating an array with new[], the compiler must reserve an extra bit to recall how many elements there are in the array. Typically, this extra info is allocated at the beginning of the block, and the remaining portion is what's returned to the user. When delete[] is called, the compiler subtracts some bytes to the pointer passed by the user to access the size information. So, if delete is called instead, the compiler will request the underlying memory system to free a pointer that is off its original position by some bytes! Needles to say, this can make the app crash.
(Other schemes for storing the array size information exist, that do no suffer from this inconvenience; but generally speaking, calling delete on an array allocated by new[] is undefined behavior.)

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
GeneralRe: Another String Question Pin
Nemanja Trifunovic5-Feb-02 6:39
Nemanja Trifunovic5-Feb-02 6:39 
GeneralRe: Another String Question Pin
Tim Smith5-Feb-02 15:35
Tim Smith5-Feb-02 15:35 
GeneralRe: Another String Question Pin
Nemanja Trifunovic6-Feb-02 6:11
Nemanja Trifunovic6-Feb-02 6:11 
GeneralRe: Another String Question Pin
Tim Smith5-Feb-02 15:36
Tim Smith5-Feb-02 15:36 
GeneralRe: Another String Question Pin
Jamie Hale5-Feb-02 14:41
Jamie Hale5-Feb-02 14:41 
GeneralRe: Another String Question Pin
Tim Smith5-Feb-02 15:39
Tim Smith5-Feb-02 15:39 
GeneralRe: Another String Question Pin
Nemanja Trifunovic6-Feb-02 6:16
Nemanja Trifunovic6-Feb-02 6:16 
GeneralRe: Another String Question Pin
Tim Smith5-Feb-02 15:38
Tim Smith5-Feb-02 15:38 
GeneralRe: Another String Question Pin
Tom Wright6-Feb-02 5:48
Tom Wright6-Feb-02 5:48 
Generalnot printing! Pin
5-Feb-02 4:34
suss5-Feb-02 4:34 
GeneralRe: not printing! Pin
Jon Hulatt5-Feb-02 4:48
Jon Hulatt5-Feb-02 4:48 
GeneralUSB Communications Pin
Paresh Solanki5-Feb-02 4:25
Paresh Solanki5-Feb-02 4:25 
GeneralRe: USB Communications Pin
5-Feb-02 6:34
suss5-Feb-02 6:34 
GeneralMSMASK32/MSFLXGRID Pin
5-Feb-02 4:28
suss5-Feb-02 4:28 
QuestionWMI bug or what? Pin
Mario M.5-Feb-02 4:04
Mario M.5-Feb-02 4:04 
GeneralMD5 Pin
Rickard Andersson205-Feb-02 3:19
Rickard Andersson205-Feb-02 3:19 
GeneralRe: MD5 Pin
Joel Lucsy5-Feb-02 7:51
Joel Lucsy5-Feb-02 7:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.