Reshat Sabiq wrote:
But now 2 more questions: I believe the C++ standard says that if new fails, an exception is thrown. Since exceptions are disabled in XPCOM, how can we detect the out of memory error? Does the compiler, perhaps, return 0 as it does for malloc when exceptions are disabled?
Well...gcc, at least, does not mind the -fno-exceptions and still throws an exception for a normal new. Mozilla generally ignores that problem. However, MSVC 6 (the official compiler for Windows builds) returns NULL if operator new failed.
(I think we should convert the codebase to use new (std::nothrow)...)
Also, do i understand correctly that pointers via XPConnect, such as those coming from javascript (e.g., char *), should not be reclaimed in the component called? I see 2 reasons for that: 1. they weren't allocated in the component. 2. we don't know whether malloc or new was used (or do we?).
Right. Note that XPIDL uses const char* for those pointers, which is another indication that you should not touch them.
smime.p7s
Description: S/MIME Cryptographic Signature
