Class breaks down because of additional std::string. Why?

Mikael Svensson minisip at mikaelsvensson.info
Fri Aug 10 12:17:50 CEST 2007


Hello again...

I found the problem myself. Sort of.

The problem was that I created my CacheManager object using this code:
MRef<CacheManager*> manager = new CacheManager();

When I changed it to the following everything turned out allright:
MRef<CacheManager*> manager = MRef<CacheManager*>(new CacheManager());

But a part of my original question remains: How come it broke down just 
because I added class variables to the CacheManager class?

Regards
Mikael

Mikael Svensson wrote:
> This is an excerpt of the class:
> <CODE>
> class LIBMCRYPTO_API CacheManager : public MObject {
> [snip]
> 	private:
> 		std::string getNewDirectorySetKey() const;
> 		std::string getNewCertificateSetKey() const;
> 
> 		std::map<std::string, MRef<CertificateSet*> > a;
> [snip]
> 		std::string test;
> 		int dummy;
> }
> </CODE>
> 
> Does anyone know why the application crashes when I include "std::string 
> test" in the class definition? The variable "test" is never used in any 
> function. If I remove the "test" variable everything works fine...
> 
> As a note I might add that I get the same error when trying to add more 
> "list" and "map" variables but *not* when adding more "int" variables. 
> What is it that is so special about classes that they cause memory 
> corruption just by "being there"?
> 
> Regards
> Mikael


More information about the Minisip-devel mailing list