[AGENT++] Where does Agent++ trigger DefaultLog::instance destructor from?

Jochen Katz katz at agentpp.com
Thu May 6 21:14:38 CEST 2010


Hi,

> I've set a log file by calling the function DefaultLog::init. And I've
> realized that DefaultLog::instance (AgentLogImpl) destructor function closes
> the log file. Does Agent++ trigger this release operation from another
> function?

no, it does not.

> If not, I should call destructor as following, should'nt it?
> 
> delete DefaultLog::log();

No, don't do it like this. This will cause memory corruption if
DefaultLog::log() is called again, because DefaultLog still uses the
pointer. You have to use the init function again with a null pointer.
This will delete the old pointer.

But as this does not look very good, I will add the following function
for the next release:
	static void cleanup()
	  { if (instance) delete instance; instance = 0; }


Regards,
  Jochen



More information about the AGENTPP mailing list