On Aug 22, 7:55 pm, [EMAIL PROTECTED] wrote: > [scriptable, uuid(096B7F86-2E47-4BF1-9A18-0D46D81EAEAC)]
looks like an MSCOM interface name, moderately confusing but ok: > interface IDNA : nsISupports > { attributes and methods should be interCaps not IniitalCaps: > readonly attribute string Id; > string GetLastError(); You shouldn't use the "string" type, doing so will get you into the trouble you're about to get into. > #define DNA_CID {0x096b7f86, 0x2e47, 0x4bf1, { 0x9a, 0x18, 0x0d, 0x46, > 0xd8, 0x1e, 0xae, 0xac }} Class IDs and Interface IDs are in different namespaces, but in order to avoid people being confused and think they relate, let me tell you that you should *NOT* share GUIDs between Interfaces and CIDs. mozilla style would be char mErrorMessage[200] or something (better nsCString mError;) > char m_errormsg[200]; proper signature, yay! > NS_IMETHODIMP DNA::GetId(char * *aId) > { > char* ret = NULL; strange, but OK. worrisome: > ret = reg.GetRegistryId(); > > if( ret ) > { need to verify GetRegistryId doesn't misbehave. > *aId = ret; > strncpy( m_errormsg, reg.GetLastError(), sizeof( m_errormsg ) > ); I wouldn't do this: > *aId = ""; Your C++ compiler should complain as you're assigning a const char[] to a char*. And if it manages to work, you manage to mix memory allocators which should cause a crash. (Hopefully sooner, but probably later.) correct signature for XPCOM if you use it correctly. > NS_IMETHODIMP DNA::GetLastError(char **_retval) > { Which you don't: > *_retval = m_errormsg; This is wrong. You've used the wrong memory allocator (C++ object heap for DNA instead of XPCOM nsMemory/NS_Alloc). FWIW, gecko manages to mess up occasionally w/ this stuff, but your versions of the mistakes are worse and will crash sooner than ours. _______________________________________________ dev-tech-xpcom mailing list dev-tech-xpcom@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-xpcom