Click here to Skip to main content
15,897,371 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to check the memory leak Pin
yu-jian23-Dec-10 22:03
yu-jian23-Dec-10 22:03 
AnswerRe: How to check the memory leak Pin
jk chan23-Dec-10 22:39
jk chan23-Dec-10 22:39 
AnswerRe: How to check the memory leak Pin
Hadi Dayvary23-Dec-10 22:47
professionalHadi Dayvary23-Dec-10 22:47 
AnswerRe: How to check the memory leak Pin
T210224-Dec-10 2:37
T210224-Dec-10 2:37 
AnswerRe: How to check the memory leak Pin
LunaticFringe24-Dec-10 7:54
LunaticFringe24-Dec-10 7:54 
AnswerRe: How to check the memory leak Pin
yu-jian26-Dec-10 16:09
yu-jian26-Dec-10 16:09 
GeneralRe: How to check the memory leak Pin
pacchij27-Dec-10 11:11
pacchij27-Dec-10 11:11 
Questionthrow exception after allocating some memory [modified] Pin
followait23-Dec-10 20:14
followait23-Dec-10 20:14 
How to let the code be more elegant? Just too much delete.
BTW, while not to deal the exception in side the function, try catch finally can't be used.

void f()
{
	char * buf = new char[128];
	...
	if (...)
	{
		delete []buf;
		throw runtime_error("...");
	}
	...
	if (...)
	{
		delete []buf;
		throw runtime_error("...");
	}
}


=====================

I think what I need is something like constructor and destructor, but for a function.
By overriding operator() of a class may solve some problem, but the function it hard to be re-entrantable, and other misc problems.

Most of the cases the function should be short, so this couldn't be a problem, but in some rare case, it has to deal a lot of data,
and the function looks very long.

modified on Friday, December 24, 2010 3:38 AM

QuestionRe: throw exception after allocating some memory Pin
CPallini23-Dec-10 21:12
mveCPallini23-Dec-10 21:12 
AnswerRe: throw exception after allocating some memory Pin
followait23-Dec-10 21:38
followait23-Dec-10 21:38 
QuestionRe: throw exception after allocating some memory Pin
CPallini23-Dec-10 22:00
mveCPallini23-Dec-10 22:00 
AnswerRe: throw exception after allocating some memory Pin
bleedingfingers23-Dec-10 21:40
bleedingfingers23-Dec-10 21:40 
AnswerRe: throw exception after allocating some memory Pin
jk chan23-Dec-10 21:46
jk chan23-Dec-10 21:46 
GeneralRe: throw exception after allocating some memory Pin
followait24-Dec-10 5:07
followait24-Dec-10 5:07 
GeneralRe: throw exception after allocating some memory Pin
Eugen Podsypalnikov24-Dec-10 8:48
Eugen Podsypalnikov24-Dec-10 8:48 
GeneralRe: throw exception after allocating some memory Pin
followait24-Dec-10 20:39
followait24-Dec-10 20:39 
GeneralRe: throw exception after allocating some memory Pin
Eugen Podsypalnikov24-Dec-10 23:26
Eugen Podsypalnikov24-Dec-10 23:26 
GeneralRe: throw exception after allocating some memory Pin
jk chan26-Dec-10 21:30
jk chan26-Dec-10 21:30 
AnswerRe: throw exception after allocating some memory Pin
Aescleal24-Dec-10 3:59
Aescleal24-Dec-10 3:59 
GeneralRe: throw exception after allocating some memory Pin
followait24-Dec-10 5:11
followait24-Dec-10 5:11 
QuestionHow to restrict drag and drop from explorer to my application? Pin
krishnakumartm23-Dec-10 3:15
krishnakumartm23-Dec-10 3:15 
AnswerRe: How to restrict drag and drop from explorer to my application? Pin
David Crow23-Dec-10 15:50
David Crow23-Dec-10 15:50 
QuestionHow can i use a exported class from DLL with .EXP and .DLL File Pin
bankey101023-Dec-10 2:14
bankey101023-Dec-10 2:14 
AnswerRe: How can i use a exported class from DLL with .EXP and .DLL File Pin
T210223-Dec-10 12:48
T210223-Dec-10 12:48 
QuestionData Structure library for windows Pin
pandit8423-Dec-10 2:08
pandit8423-Dec-10 2: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.