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
[]) {
12 nsIServiceManager
* servMgr
;
13 rv
= NS_InitXPCOM2(&servMgr
, nullptr, nullptr);
14 NS_ASSERTION(NS_SUCCEEDED(rv
), "NS_InitXPCOM failed");
16 // try loading a component and releasing it to see if it leaks
17 if (argc
> 1 && argv
[1] != nullptr) {
18 char* cidStr
= argv
[1];
19 nsISupports
* obj
= nullptr;
20 if (cidStr
[0] == '{') {
23 rv
= CallCreateInstance(cid
, &obj
);
26 rv
= CallCreateInstance(cidStr
, &obj
);
28 if (NS_SUCCEEDED(rv
)) {
29 printf("Successfully created %s\n", cidStr
);
32 printf("Failed to create %s (%x)\n", cidStr
, rv
);
36 rv
= NS_ShutdownXPCOM(servMgr
);
37 NS_ASSERTION(NS_SUCCEEDED(rv
), "NS_ShutdownXPCOM failed");