Click here to Skip to main content
15,888,251 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
GeneralRe: Windows XP look and feel Pin
Christian Graus18-Sep-05 18:09
protectorChristian Graus18-Sep-05 18:09 
GeneralRe: Windows XP look and feel Pin
Member 223710418-Sep-05 19:59
Member 223710418-Sep-05 19:59 
GeneralRe: Windows XP look and feel Pin
toxcct18-Sep-05 20:33
toxcct18-Sep-05 20:33 
GeneralRe: Windows XP look and feel Pin
Member 223710418-Sep-05 23:37
Member 223710418-Sep-05 23:37 
GeneralRe: Windows XP look and feel Pin
Christian Graus19-Sep-05 10:53
protectorChristian Graus19-Sep-05 10:53 
GeneralRe: Windows XP look and feel Pin
Taka Muraoka18-Sep-05 23:29
Taka Muraoka18-Sep-05 23:29 
Questionconsole to dialog Pin
Member 216100418-Sep-05 16:19
Member 216100418-Sep-05 16:19 
AnswerRe: console to dialog Pin
Christian Graus18-Sep-05 17:26
protectorChristian Graus18-Sep-05 17:26 
GeneralRe: console to dialog Pin
Member 216100418-Sep-05 17:44
Member 216100418-Sep-05 17:44 
GeneralRe: console to dialog Pin
Christian Graus18-Sep-05 17:48
protectorChristian Graus18-Sep-05 17:48 
GeneralRe: console to dialog Pin
Member 216100418-Sep-05 18:09
Member 216100418-Sep-05 18:09 

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.