nsIServiceManager* servMan = nsnull; rv = NS_InitXPCOM2(&servMan, directory, provider); if (provider) { delete provider; }
if (NS_SUCCEEDED(rv)) { nsIServiceManager* servMan = nsnull; rv = NS_InitXPCOM2(&servMan, directory, provider); if (provider) { delete provider; }
XPCOM_NATIVE(initXPCOM) (JNIEnv* env, jclass, jobject aMozBinDirectory,                         jobject aAppFileLocProvider){  nsresult rv = NS_OK;  if (InitializeJavaGlobals(env))  {    // Create an nsILocalFile from given java.io.File    nsCOMPtr<nsILocalFile> directory;    if (aMozBinDirectory) {      rv = File_to_nsILocalFile(env, aMozBinDirectory, getter_AddRefs(directory));    }    if (NS_SUCCEEDED(rv)) {      nsAppFileLocProviderProxy* provider = nsnull;      if (aAppFileLocProvider) {        provider = new nsAppFileLocProviderProxy(env, aAppFileLocProvider);      }      nsIServiceManager* servMan = nsnull;      rv = NS_InitXPCOM2(&servMan, directory, provider);      if (provider) {        delete provider;      }      jobject java_stub = nsnull;      if (NS_SUCCEEDED(rv)) {        // wrap xpcom instance        JavaXPCOMInstance* inst;        inst = CreateJavaXPCOMInstance(servMan, &NS_GET_IID(nsIServiceManager));        NS_RELEASE(servMan);   // JavaXPCOMInstance has owning ref        if (inst) {          // create java stub          java_stub = CreateJavaWrapper(env, "nsIServiceManager");          if (java_stub) {            // Associate XPCOM object w/ Java stub            AddJavaXPCOMBinding(env, java_stub, inst);            return java_stub;          }        }      }    }  }  ThrowXPCOMException(env, rv, "Failure in initXPCOM");  FreeJavaGlobals(env);  return nsnull;}