Click here to Skip to main content
15,896,111 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: When to delete, and when to NULL? Pin
Jon Sagara15-Nov-01 10:58
Jon Sagara15-Nov-01 10:58 
GeneralRe: When to delete, and when to NULL? Pin
Jim A. Johnson15-Nov-01 12:15
Jim A. Johnson15-Nov-01 12:15 
GeneralRe: When to delete, and when to NULL? Pin
Jon Sagara15-Nov-01 12:36
Jon Sagara15-Nov-01 12:36 
GeneralRe: When to delete, and when to NULL? Pin
Tim Smith15-Nov-01 12:54
Tim Smith15-Nov-01 12:54 
GeneralRe: When to delete, and when to NULL? Pin
Colin Urquhart15-Nov-01 15:47
Colin Urquhart15-Nov-01 15:47 
GeneralRe: When to delete, and when to NULL? Pin
Michael Dunn15-Nov-01 19:07
sitebuilderMichael Dunn15-Nov-01 19:07 
GeneralRe: When to delete, and when to NULL? Pin
#realJSOP16-Nov-01 0:50
professional#realJSOP16-Nov-01 0:50 
AnswerRe: When to delete, and when to NULL? Pin
Gert Boddaert15-Nov-01 5:06
Gert Boddaert15-Nov-01 5:06 
void NewPointer()
{
if (m_pPointer == NULL)
{
m_pPointer = new(MyCPointClass);
if (NULL != pPointer && m_pPointer->NewPoint()) // NewPoint is a function, right?
{
return;
}
else
{
delete(m_pPointer);
m_pPointer = NULL; // avoid deleting the memory twice! deleting a NULL pointer is safe, but has a performance penalty since a call to the C-runtime library is done.
}
}
}

void DeletePointer()
{
if (NULL != m_pPointer)
{
delete m_pPointer;
m_pPointer = NULL;
}
}

if you insert
m_pPointer = NULL
somewhere in your code between NewPointer() and DeletePointer(), then yes you have a memory leak.

--------------------------------------------------
If my messages appear curt, I apologize.
I try to be brief to save your time as well as mine.
--------------------------------------------------

AnswerRe: Thankyou All. Pin
Chambers15-Nov-01 9:32
Chambers15-Nov-01 9:32 
QuestionHow can I open default mail client from my app in VC? Pin
Karavaev Denis15-Nov-01 2:07
Karavaev Denis15-Nov-01 2:07 
AnswerRe: How can I open default mail client from my app in VC? Pin
Nish Nishant15-Nov-01 2:18
sitebuilderNish Nishant15-Nov-01 2:18 
GeneralIt's only opening New message window. I need all programm(etc Outlook, The bat, opera ...) Pin
Karavaev Denis15-Nov-01 3:01
Karavaev Denis15-Nov-01 3:01 
GeneralRe: It's only opening New message window. I need all programm(etc Outlook, The bat, opera ...) Pin
Nish Nishant15-Nov-01 3:10
sitebuilderNish Nishant15-Nov-01 3:10 
GeneralRe: It's only opening New message window. I need all programm(etc Outlook, The bat, opera ...) Pin
15-Nov-01 3:14
suss15-Nov-01 3:14 
GeneralRe: It's only opening New message window. I need all programm(etc Outlook, The bat, opera ...) Pin
Nish Nishant15-Nov-01 3:29
sitebuilderNish Nishant15-Nov-01 3:29 
General:) Pin
Masaaki Onishi15-Nov-01 4:07
Masaaki Onishi15-Nov-01 4:07 
General.tbl Files Pin
Ray Kinsella15-Nov-01 1:21
Ray Kinsella15-Nov-01 1:21 
GeneralRe: .tbl Files Pin
Bill Wilson15-Nov-01 13:51
Bill Wilson15-Nov-01 13:51 
GeneralRe: .tbl Files Pin
Ray Kinsella15-Nov-01 22:26
Ray Kinsella15-Nov-01 22:26 
GeneralRe: .tbl Files Pin
Bill Wilson16-Nov-01 7:08
Bill Wilson16-Nov-01 7:08 
QuestionHow to recognize a word under mouse position? Pin
14-Nov-01 21:53
suss14-Nov-01 21:53 
AnswerRe: How to recognize a word under mouse position? Pin
Christian Graus15-Nov-01 8:48
protectorChristian Graus15-Nov-01 8:48 
AnswerRe: How to recognize a word under mouse position? Pin
Joaquín M López Muñoz15-Nov-01 9:41
Joaquín M López Muñoz15-Nov-01 9:41 
AnswerRe: How to recognize a word under mouse position? Pin
Kind15-Nov-01 15:03
Kind15-Nov-01 15:03 
GeneralRe: How to recognize a word under mouse position? Pin
Saeed Torabi18-Dec-01 23:37
Saeed Torabi18-Dec-01 23:37 

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.