Click here to Skip to main content
16,009,391 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: c++ functions Pin
_AnsHUMAN_ 13-Jun-06 18:48
_AnsHUMAN_ 13-Jun-06 18:48 
QuestionUsing Binary Data Directly in CPP Source Files Pin
JSadleir13-Jun-06 18:38
JSadleir13-Jun-06 18:38 
AnswerRe: Using Binary Data Directly in CPP Source Files Pin
Stephen Hewitt14-Jun-06 20:44
Stephen Hewitt14-Jun-06 20:44 
GeneralRe: Using Binary Data Directly in CPP Source Files Pin
JSadleir18-Jun-06 15:52
JSadleir18-Jun-06 15:52 
QuestionHow to verify a pointer is valid? [modified] Pin
flyingxu13-Jun-06 17:25
flyingxu13-Jun-06 17:25 
AnswerRe: How to verify a pointer is valid? Pin
Sarath C13-Jun-06 17:43
Sarath C13-Jun-06 17:43 
GeneralRe: How to verify a pointer is valid? [modified] Pin
Stephen Hewitt13-Jun-06 18:09
Stephen Hewitt13-Jun-06 18:09 
AnswerRe: How to verify a pointer is valid? [modified] Pin
Nibu babu thomas13-Jun-06 17:55
Nibu babu thomas13-Jun-06 17:55 
flyingxu wrote:
But now I want to use the pointer of pSave, can I verify if pSave is valid or not before I use it?
try/catch?
or any method else?


Look up _set_new_handler, _set_new_mode, _query_new_handler, AfxSetNewHandler (this is not documented).

The above functions transfers control to your error-handling mechanism if the new operator fails to allocate memory.

These functions (except for _set_new_mode and _query_new_handler) take a function pointer as an argument and returns the old one. The _query_new_handler function returns the address of the current new handler.

Make sure you set the old one back before exiting.

PNH old_handler = _set_new_handler( my_handler );
// Code that requires my_handler
_set_new_handler( old_handler )
// Code that requires old_handler



Nibu thomas
A Developer

Programming tips[^]  My site[^]

AnswerRe: How to verify a pointer is valid? Pin
grigsoft13-Jun-06 18:09
grigsoft13-Jun-06 18:09 
AnswerRe: How to verify a pointer is valid? Pin
Ganesh_T13-Jun-06 18:37
Ganesh_T13-Jun-06 18:37 
AnswerRe: How to verify a pointer is valid? Pin
Laxman Auti13-Jun-06 18:49
Laxman Auti13-Jun-06 18:49 
AnswerRe: How to verify a pointer is valid? Pin
Tim Paaschen13-Jun-06 19:35
Tim Paaschen13-Jun-06 19:35 
Questiongraphical error Pin
anmol m13-Jun-06 17:12
anmol m13-Jun-06 17:12 
AnswerRe: graphical error Pin
Ganesh_T13-Jun-06 18:40
Ganesh_T13-Jun-06 18:40 
AnswerRe: graphical error Pin
Laxman Auti13-Jun-06 18:45
Laxman Auti13-Jun-06 18:45 
AnswerRe: graphical error Pin
khan++13-Jun-06 18:46
khan++13-Jun-06 18:46 
GeneralRe: graphical error Pin
anmol m15-Jun-06 7:11
anmol m15-Jun-06 7:11 
GeneralRe: graphical error Pin
khan++15-Jun-06 21:12
khan++15-Jun-06 21:12 
QuestionA newb needs help. Pin
zach713-Jun-06 16:01
zach713-Jun-06 16:01 
AnswerRe: A newb needs help. Pin
Mark F.13-Jun-06 17:15
Mark F.13-Jun-06 17:15 
AnswerRe: A newb needs help. Pin
Ganesh_T13-Jun-06 18:46
Ganesh_T13-Jun-06 18:46 
AnswerRe: A newb needs help. Pin
Laxman Auti13-Jun-06 18:53
Laxman Auti13-Jun-06 18:53 
Questionpopup menu in a listbox [modified] Pin
locoone13-Jun-06 15:48
locoone13-Jun-06 15:48 
AnswerRe: popup menu in a listbox Pin
Sarath C13-Jun-06 17:38
Sarath C13-Jun-06 17:38 
AnswerRe: popup menu in a listbox Pin
Hamid_RT13-Jun-06 19:41
Hamid_RT13-Jun-06 19:41 

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.