michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsIServiceManager.h" michael@0: michael@0: // Gee this seems simple! It's for testing for memory leaks with Purify. michael@0: michael@0: void main(int argc, char* argv[]) michael@0: { michael@0: nsresult rv; michael@0: nsIServiceManager* servMgr; michael@0: rv = NS_InitXPCOM2(&servMgr, nullptr, nullptr); michael@0: NS_ASSERTION(NS_SUCCEEDED(rv), "NS_InitXPCOM failed"); michael@0: michael@0: // try loading a component and releasing it to see if it leaks michael@0: if (argc > 1 && argv[1] != nullptr) { michael@0: char* cidStr = argv[1]; michael@0: nsISupports* obj = nullptr; michael@0: if (cidStr[0] == '{') { michael@0: nsCID cid; michael@0: cid.Parse(cidStr); michael@0: rv = CallCreateInstance(cid, &obj); michael@0: } michael@0: else { michael@0: // contractID case: michael@0: rv = CallCreateInstance(cidStr, &obj); michael@0: } michael@0: if (NS_SUCCEEDED(rv)) { michael@0: printf("Successfully created %s\n", cidStr); michael@0: NS_RELEASE(obj); michael@0: } michael@0: else { michael@0: printf("Failed to create %s (%x)\n", cidStr, rv); michael@0: } michael@0: } michael@0: michael@0: rv = NS_ShutdownXPCOM(servMgr); michael@0: NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed"); michael@0: }