Click here to Skip to main content
16,016,800 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: NOPE Pin
toxcct23-Nov-07 3:41
toxcct23-Nov-07 3:41 
GeneralRe: NOPE Pin
George_George23-Nov-07 5:15
George_George23-Nov-07 5:15 
QuestionWhere to put delete[] to prevent memory leaks? Pin
Priya_Sundar22-Nov-07 23:47
Priya_Sundar22-Nov-07 23:47 
AnswerRe: Where to put delete[] to prevent memory leaks? Pin
Nelek22-Nov-07 23:57
protectorNelek22-Nov-07 23:57 
GeneralRe: Where to put delete[] to prevent memory leaks? Pin
CPallini23-Nov-07 0:17
mveCPallini23-Nov-07 0:17 
GeneralRe: Where to put delete[] to prevent memory leaks? Pin
Priya_Sundar23-Nov-07 0:42
Priya_Sundar23-Nov-07 0:42 
GeneralRe: Where to put delete[] to prevent memory leaks? Pin
CPallini23-Nov-07 2:08
mveCPallini23-Nov-07 2:08 
GeneralRe: Where to put delete[] to prevent memory leaks? [modified] Pin
Nelek23-Nov-07 2:02
protectorNelek23-Nov-07 2:02 
Can you explain a bit what are you referring to? I don't understand you well and I want to learn more.

That this is not the best option... I agree (I know I am just a low/middle skilled programmer that needs to learn more), but... what do you mean with the standard behaviour of windows api? can you put an example?

Maybe something like this?
LPTSTR COperDialog::ConvertResourceStringIdToLptstr(UINT nResString, LPSTR pStr)   //parameter added
{
   CString strLoad;
   strLoad.LoadString(nResString);
   pStr = new TCHAR[strLoad.GetLength()+1];
   CHECK_FOR_NULL(pStr)
   _tcscpy(pStr,strLoad);
   return pStr;
}
//
void COperDialog::AddProjectRootItem()
{
   TV_INSERTSTRUCT curTreeItem;
   curTreeItem.hParent =TVI_ROOT;
   curTreeItem.hInsertAfter = TVI_ROOT;
   curTreeItem.item.iImage = 0;
   curTreeItem.item.iSelectedImage = 0;
;  
   //New Version
   LPSTR pMyLpstr = NULL;   
   curTreeItem.item.pszText = ConvertResourceStringIdToLptstr(IDS_PROJECT, pMyLpstr);
;
   delete [] pMyLpstr;      pMyLpstr = NULL; //As it was
   curTreeItem.item.cchTextMax=15;
   curTreeItem.item.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT;
   htrProjectRoot = m_Edit->InsertItem(&curTreeItem);
}


Is this option better than the other one?


-- modified at 8:11 Friday 23rd November, 2007


-- modified at 8:12 Friday 23rd November, 2007

Greetings.

--------
M.D.V. Wink | ;)

If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson

GeneralRe: Where to put delete[] to prevent memory leaks? Pin
CPallini23-Nov-07 2:18
mveCPallini23-Nov-07 2:18 
GeneralRe: Where to put delete[] to prevent memory leaks? Pin
Nelek23-Nov-07 4:20
protectorNelek23-Nov-07 4:20 
GeneralRe: Where to put delete[] to prevent memory leaks? Pin
CPallini23-Nov-07 5:28
mveCPallini23-Nov-07 5:28 
GeneralRe: Where to put delete[] to prevent memory leaks? Pin
Nelek25-Nov-07 21:22
protectorNelek25-Nov-07 21:22 
GeneralRe: Where to put delete[] to prevent memory leaks? Pin
CPallini25-Nov-07 21:41
mveCPallini25-Nov-07 21:41 
GeneralRe: Where to put delete[] to prevent memory leaks? Pin
Priya_Sundar25-Nov-07 22:34
Priya_Sundar25-Nov-07 22:34 
GeneralRe: Where to put delete[] to prevent memory leaks? Pin
Priya_Sundar23-Nov-07 0:41
Priya_Sundar23-Nov-07 0:41 
AnswerYou don't need such a mess Pin
CPallini23-Nov-07 0:09
mveCPallini23-Nov-07 0:09 
GeneralRe: You don't need such a mess Pin
Priya_Sundar23-Nov-07 0:39
Priya_Sundar23-Nov-07 0:39 
GeneralRe: You don't need such a mess Pin
CPallini23-Nov-07 0:52
mveCPallini23-Nov-07 0:52 
GeneralRe: You don't need such a mess Pin
Priya_Sundar23-Nov-07 1:03
Priya_Sundar23-Nov-07 1:03 
GeneralRe: You don't need such a mess Pin
CPallini23-Nov-07 2:34
mveCPallini23-Nov-07 2:34 
GeneralRe: You don't need such a mess Pin
Priya_Sundar25-Nov-07 22:29
Priya_Sundar25-Nov-07 22:29 
QuestionVC++ 6 debugging problem Pin
shine joseph22-Nov-07 22:42
shine joseph22-Nov-07 22:42 
AnswerRe: VC++ 6 debugging problem Pin
KarstenK22-Nov-07 23:23
mveKarstenK22-Nov-07 23:23 
GeneralRe: VC++ 6 debugging problem Pin
shine joseph27-Nov-07 1:07
shine joseph27-Nov-07 1:07 
Questionhow to print the value from registry Pin
dadacncn22-Nov-07 22:40
dadacncn22-Nov-07 22:40 

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.