2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-07-28 12:01:55 +04:00
|
|
|
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
|
1999-07-28 12:28:10 +04:00
|
|
|
// Gee this seems simple! It's for testing for memory leaks with Purify.
|
1999-07-28 12:01:55 +04:00
|
|
|
|
1999-07-28 12:28:10 +04:00
|
|
|
void main(int argc, char* argv[])
|
1999-07-28 12:01:55 +04:00
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
nsIServiceManager* servMgr;
|
2001-10-16 07:35:52 +04:00
|
|
|
rv = NS_InitXPCOM2(&servMgr, NULL, NULL);
|
1999-07-28 12:01:55 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_InitXPCOM failed");
|
1999-07-28 12:28:10 +04:00
|
|
|
|
|
|
|
// try loading a component and releasing it to see if it leaks
|
2012-07-30 18:20:58 +04:00
|
|
|
if (argc > 1 && argv[1] != nullptr) {
|
1999-09-28 22:01:47 +04:00
|
|
|
char* cidStr = argv[1];
|
2012-07-30 18:20:58 +04:00
|
|
|
nsISupports* obj = nullptr;
|
1999-09-28 22:01:47 +04:00
|
|
|
if (cidStr[0] == '{') {
|
|
|
|
nsCID cid;
|
|
|
|
cid.Parse(cidStr);
|
2004-11-01 21:50:36 +03:00
|
|
|
rv = CallCreateInstance(cid, &obj);
|
1999-09-28 22:01:47 +04:00
|
|
|
}
|
|
|
|
else {
|
2000-09-14 03:57:52 +04:00
|
|
|
// contractID case:
|
2004-11-01 21:50:36 +03:00
|
|
|
rv = CallCreateInstance(cidStr, &obj);
|
1999-09-28 22:01:47 +04:00
|
|
|
}
|
1999-07-28 12:28:10 +04:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
1999-09-28 22:01:47 +04:00
|
|
|
printf("Successfully created %s\n", cidStr);
|
1999-07-28 12:28:10 +04:00
|
|
|
NS_RELEASE(obj);
|
|
|
|
}
|
|
|
|
else {
|
1999-09-28 22:01:47 +04:00
|
|
|
printf("Failed to create %s (%x)\n", cidStr, rv);
|
1999-07-28 12:28:10 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-07-28 12:01:55 +04:00
|
|
|
rv = NS_ShutdownXPCOM(servMgr);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");
|
|
|
|
}
|