Click here to Skip to main content
15,921,716 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Tabs with right close button (Firefox like) Pin
Moak27-Jun-06 0:26
Moak27-Jun-06 0:26 
QuestionHow to know if a pointer is valid? Pin
hatemtalbi26-Jun-06 3:43
hatemtalbi26-Jun-06 3:43 
QuestionRe: How to know if a pointer is valid? Pin
David Crow26-Jun-06 3:48
David Crow26-Jun-06 3:48 
AnswerRe: How to know if a pointer is valid? [modified] Pin
Stephen Hewitt26-Jun-06 16:53
Stephen Hewitt26-Jun-06 16:53 
GeneralRe: How to know if a pointer is valid? Pin
David Crow27-Jun-06 3:08
David Crow27-Jun-06 3:08 
AnswerRe: How to know if a pointer is valid? Pin
Viorel.26-Jun-06 3:52
Viorel.26-Jun-06 3:52 
GeneralRe: How to know if a pointer is valid? Pin
hatemtalbi26-Jun-06 3:57
hatemtalbi26-Jun-06 3:57 
GeneralRe: How to know if a pointer is valid? [modified] Pin
Stephen Hewitt26-Jun-06 18:03
Stephen Hewitt26-Jun-06 18:03 
You are asking for trouble if you rely on these APIs to tell if memory is safe to use. For example with heaps when you free a block it doesn't mean the memory is deallocated straight away; it can be marked as free and recycled. This is how heaps work. For example: if IsBadReadPtr returns TRUE you know for sure that the memory isn't safe to read; but if it returns FALSE it does ***NOT*** mean that the memory is safe to read - it could be on the heap's free list for example.

Most people don't believe when I tell them this. The following code shows this effect in action:
int *pInt = new int;
delete pInt;
ASSERT( AfxIsValidAddress(pInt, sizeof(int)) );


If this practice was safe the ASSERT should fire: it doesn't. The memory is being cached in the heap but it is definitely ***NOT*** safe to use it. DO NOT USE THIS TECHNIQUE!

Steve
GeneralRe: How to know if a pointer is valid? Pin
David Crow27-Jun-06 3:05
David Crow27-Jun-06 3:05 
GeneralRe: How to know if a pointer is valid? Pin
Stephen Hewitt27-Jun-06 3:56
Stephen Hewitt27-Jun-06 3:56 
AnswerRe: How to know if a pointer is valid? Pin
Sarath C26-Jun-06 3:52
Sarath C26-Jun-06 3:52 
AnswerRe: How to know if a pointer is valid? Pin
Roland Pibinger26-Jun-06 9:33
Roland Pibinger26-Jun-06 9:33 
GeneralRe: How to know if a pointer is valid? Pin
Stephen Hewitt26-Jun-06 19:42
Stephen Hewitt26-Jun-06 19:42 
QuestionGet Motherboard sensors Pin
honae26-Jun-06 3:15
honae26-Jun-06 3:15 
QuestionRe: Get Motherboard sensors Pin
David Crow26-Jun-06 3:39
David Crow26-Jun-06 3:39 
AnswerRe: Get Motherboard sensors Pin
honae26-Jun-06 3:50
honae26-Jun-06 3:50 
QuestionRe: Get Motherboard sensors Pin
David Crow26-Jun-06 4:01
David Crow26-Jun-06 4:01 
AnswerRe: Get Motherboard sensors [modified] Pin
honae26-Jun-06 4:17
honae26-Jun-06 4:17 
QuestionRe: Get Motherboard sensors Pin
David Crow26-Jun-06 4:40
David Crow26-Jun-06 4:40 
AnswerRe: Get Motherboard sensors [modified] Pin
honae26-Jun-06 4:49
honae26-Jun-06 4:49 
GeneralRe: Get Motherboard sensors Pin
David Crow26-Jun-06 5:03
David Crow26-Jun-06 5:03 
QuestionAppend text to a rich edit w/o using ReplaceSel Pin
KellyR26-Jun-06 3:12
KellyR26-Jun-06 3:12 
AnswerRe: Append text to a rich edit w/o using ReplaceSel Pin
Justin Tay26-Jun-06 3:33
Justin Tay26-Jun-06 3:33 
GeneralRe: Append text to a rich edit w/o using ReplaceSel Pin
KellyR26-Jun-06 4:04
KellyR26-Jun-06 4:04 
Questionhow we add menu captions in runtime [modified] Pin
vasusree26-Jun-06 3:04
vasusree26-Jun-06 3:04 

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.