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

C / C++ / MFC

 
AnswerRe: MFC Pin
The NULL Developer18-Sep-05 21:18
professionalThe NULL Developer18-Sep-05 21:18 
QuestionChild window in splitter window Pin
The NULL Developer18-Sep-05 20:58
professionalThe NULL Developer18-Sep-05 20:58 
Questionhow to save the toolbar state to a .ini file? Pin
benben18-Sep-05 20:47
benben18-Sep-05 20:47 
AnswerRe: how to save the toolbar state to a .ini file? Pin
Neelesh K J Jain18-Sep-05 21:02
Neelesh K J Jain18-Sep-05 21:02 
QuestionHow to set Range of Spin control to 32 bit value ? Pin
dhawan_boss18-Sep-05 19:58
dhawan_boss18-Sep-05 19:58 
AnswerRe: How to set Range of Spin control to 32 bit value ? Pin
David Crow19-Sep-05 8:13
David Crow19-Sep-05 8:13 
QuestionNotification Pin
karmendra_js18-Sep-05 19:52
karmendra_js18-Sep-05 19:52 
AnswerRe: Notification Pin
Neelesh K J Jain18-Sep-05 21:15
Neelesh K J Jain18-Sep-05 21:15 
QuestionCScrollBar Pin
Nishad S18-Sep-05 19:18
Nishad S18-Sep-05 19:18 
QuestionHow to create this setup wizard program? (screen-shot attached) Pin
Jason Liu18-Sep-05 18:48
Jason Liu18-Sep-05 18:48 
AnswerRe: How to create this setup wizard program? (screen-shot attached) Pin
ThatsAlok18-Sep-05 18:51
ThatsAlok18-Sep-05 18:51 
GeneralRe: How to create this setup wizard program? (screen-shot attached) Pin
Jason Liu18-Sep-05 18:56
Jason Liu18-Sep-05 18:56 
AnswerRe: How to create this setup wizard program? (screen-shot attached) Pin
ThatsAlok18-Sep-05 19:05
ThatsAlok18-Sep-05 19:05 
GeneralRe: How to create this setup wizard program? (screen-shot attached) Pin
bugDanny19-Sep-05 4:54
bugDanny19-Sep-05 4:54 
GeneralRe: How to create this setup wizard program? (screen-shot attached) Pin
Trollslayer19-Sep-05 1:27
mentorTrollslayer19-Sep-05 1:27 
Questiondelete returned point question Pin
followait18-Sep-05 16:37
followait18-Sep-05 16:37 
AnswerRe: delete returned point question Pin
Christian Graus18-Sep-05 17:20
protectorChristian Graus18-Sep-05 17:20 
GeneralRe: delete returned point question Pin
followait18-Sep-05 22:49
followait18-Sep-05 22:49 
GeneralRe: delete returned point question Pin
Matt Godbolt18-Sep-05 23:29
Matt Godbolt18-Sep-05 23:29 
In general, it's up to the callee to ensure any newly-allocated memory which is returned by a function is properly deleted. In the case of strings, for modern applications, returning a std::string is the easiest way of ensuring no memory is leaked (or even prematurely freed).

If you're dealing with legacy code that returns a 'char *' or similar, and expects the caller to free memory (a la strdup()), then you could consider a smart pointer of some type - but be aware the default STL smart pointers (std::auto_ptr) uses 'delete' on any memory it sees. This is not necessarily the same as calling 'free()' on the returned object (or indeed delete[] for arrays).

Also be aware that smart pointers have a lot of their own issues - notably ownership. Boost gets around this by having shared and scoped pointers - if you have access to boost, then using a scoped_array might be appropriate, if the function you're calling allocates memory with new char[].

If not, you'll have to write your own smart pointer - which can be tricky to get right; but for very simple cases is only a few lines of code.

Matt Godbolt
Engineer, ProFactor Software
StyleManager project
GeneralRe: delete returned point question Pin
khan++18-Sep-05 23:35
khan++18-Sep-05 23:35 
QuestionWindows XP look and feel Pin
Member 223710418-Sep-05 16:21
Member 223710418-Sep-05 16:21 
AnswerRe: Windows XP look and feel Pin
Christian Graus18-Sep-05 17:20
protectorChristian Graus18-Sep-05 17:20 
GeneralRe: Windows XP look and feel Pin
benjnp18-Sep-05 17:37
benjnp18-Sep-05 17:37 
GeneralRe: Windows XP look and feel Pin
Christian Graus18-Sep-05 17:39
protectorChristian Graus18-Sep-05 17:39 
GeneralRe: Windows XP look and feel Pin
Member 223710418-Sep-05 18:08
Member 223710418-Sep-05 18:08 

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.