我有這樣的事情:這是內存泄漏嗎?應該怎麼做?
void Test(void)
{
char errorMessage[256];
spintf(errorMessage,... blablabla);
throw new CustomException(errorMessage);
}
這會不會造成內存泄漏的errorMessage因爲將不被釋放?或者當在try {} catch中訪問異常的消息時,這會導致異常,因爲errorMessage在從函數出去時已經被釋放了。
在此先感謝。
什麼是CustomException構造函數的定義?您的問題的答案取決於是否複製errorMessage字符串。 – mcdave 2010-01-24 12:55:10
錯誤字符串未被複制 – 2010-01-24 13:07:13