Click here to Skip to main content
15,121,505 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: very urgent help needed in openmp Pin
loyal ginger16-Apr-10 8:54
Memberloyal ginger16-Apr-10 8:54 
GeneralRe: very urgent help needed in openmp Pin
aruneshjoshi16-Apr-10 9:06
Memberaruneshjoshi16-Apr-10 9:06 
QuestionRe: very urgent help needed in openmp Pin
David Crow16-Apr-10 9:29
MemberDavid Crow16-Apr-10 9:29 
AnswerRe: very urgent help needed in openmp Pin
aruneshjoshi16-Apr-10 9:44
Memberaruneshjoshi16-Apr-10 9:44 
GeneralRe: very urgent help needed in openmp Pin
rchrd16-Apr-10 10:26
Memberrchrd16-Apr-10 10:26 
QuestionAllocation/Deallocation from Memory Pool [Solved] Pin
Skippums16-Apr-10 5:17
MemberSkippums16-Apr-10 5:17 
AnswerRe: Allocation/Deallocation from Memory Pool Pin
«_Superman_»16-Apr-10 7:41
professional«_Superman_»16-Apr-10 7:41 
AnswerRe: Allocation/Deallocation from Memory Pool [Solved] Pin
cmk16-Apr-10 10:06
Membercmk16-Apr-10 10:06 
For yor case it works.

As a general rule it won't.

delete[] against an object, whose type has a destructor will call the 'vector deleting destructor', which will call the destructor for each element.

The problem is the number of elements.

When new[] is called on a type with a destructor:
1. malloc a block large enough to hold the reqested # of elements, the actual block size will be rounded up to some grain size.
2. store the actual block size (bytes) with the block for free().
3. store the requested # of elements with the block so delete[] can iterate over them and call ~().

When you call delete on a different (sized) type the # of elements stored with the block will be wrong and you will either call ~() on too few or too many elements.

If too few then you could have a memory leak if the destructor frees resources.

If too many then you corrupt the heap.
...cmk

The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack

AnswerRe: Allocation/Deallocation from Memory Pool [Solved] Pin
Gwenio16-Apr-10 10:21
MemberGwenio16-Apr-10 10:21 
QuestionCan we Insert table into SDI Application ? Pin
Khathar16-Apr-10 2:54
MemberKhathar16-Apr-10 2:54 
AnswerRe: Can we Insert table into SDI Application ? Pin
Maximilien16-Apr-10 3:50
MemberMaximilien16-Apr-10 3:50 
AnswerRe: Can we Insert table into SDI Application ? Pin
«_Superman_»16-Apr-10 7:47
professional«_Superman_»16-Apr-10 7:47 
QuestionCComboBox the max text length ?? Pin
Arrin16-Apr-10 1:28
MemberArrin16-Apr-10 1:28 
AnswerRe: CComboBox the max text length ?? SOLVED Pin
Arrin16-Apr-10 1:43
MemberArrin16-Apr-10 1:43 
QuestionWorker Thread GUI Pin
MsmVc15-Apr-10 23:21
MemberMsmVc15-Apr-10 23:21 
AnswerRe: Worker Thread GUI Pin
Cedric Moonen15-Apr-10 23:33
MemberCedric Moonen15-Apr-10 23:33 
AnswerRe: Worker Thread GUI Pin
Eugen Podsypalnikov15-Apr-10 23:44
MemberEugen Podsypalnikov15-Apr-10 23:44 
GeneralRe: Worker Thread GUI Pin
MsmVc16-Apr-10 0:07
MemberMsmVc16-Apr-10 0:07 
GeneralRe: Worker Thread GUI Pin
Cedric Moonen16-Apr-10 0:17
MemberCedric Moonen16-Apr-10 0:17 
GeneralRe: Worker Thread GUI [modified] Pin
Eugen Podsypalnikov16-Apr-10 0:38
MemberEugen Podsypalnikov16-Apr-10 0:38 
GeneralRe: Worker Thread GUI Pin
Eugen Podsypalnikov16-Apr-10 1:21
MemberEugen Podsypalnikov16-Apr-10 1:21 
GeneralRe: Worker Thread GUI Pin
Cedric Moonen16-Apr-10 0:13
MemberCedric Moonen16-Apr-10 0:13 
GeneralRe: Worker Thread GUI Pin
Eugen Podsypalnikov16-Apr-10 1:20
MemberEugen Podsypalnikov16-Apr-10 1:20 
GeneralRe: Worker Thread GUI Pin
Cedric Moonen16-Apr-10 2:01
MemberCedric Moonen16-Apr-10 2:01 
GeneralRe: Worker Thread GUI Pin
Eugen Podsypalnikov16-Apr-10 2:27
MemberEugen Podsypalnikov16-Apr-10 2:27 

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.