1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "nsIServiceManager.h"
8 // Gee this seems simple! It's for testing for memory leaks with Purify.
10 void main(int argc
, char* argv
[]) {
11 nsIServiceManager
* servMgr
;
12 nsresult rv
= NS_InitXPCOM(&servMgr
, nullptr, nullptr);
13 MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv
), "NS_InitXPCOM failed");
15 // try loading a component and releasing it to see if it leaks
16 if (argc
> 1 && argv
[1] != nullptr) {
17 char* cidStr
= argv
[1];
18 nsISupports
* obj
= nullptr;
19 if (cidStr
[0] == '{') {
22 rv
= CallCreateInstance(cid
, &obj
);
25 rv
= CallCreateInstance(cidStr
, &obj
);
27 if (NS_SUCCEEDED(rv
)) {
28 printf("Successfully created %s\n", cidStr
);
31 printf("Failed to create %s (%x)\n", cidStr
, rv
);
35 rv
= NS_ShutdownXPCOM(servMgr
);
36 MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv
), "NS_ShutdownXPCOM failed");