2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 11:12:37 +00: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 08:01:55 +00:00
|
|
|
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
|
1999-07-28 08:28:10 +00:00
|
|
|
// Gee this seems simple! It's for testing for memory leaks with Purify.
|
1999-07-28 08:01:55 +00:00
|
|
|
|
1999-07-28 08:28:10 +00:00
|
|
|
void main(int argc, char* argv[])
|
1999-07-28 08:01:55 +00:00
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
nsIServiceManager* servMgr;
|
2013-10-10 20:42:16 +00:00
|
|
|
rv = NS_InitXPCOM2(&servMgr, nullptr, nullptr);
|
1999-07-28 08:01:55 +00:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_InitXPCOM failed");
|
1999-07-28 08:28:10 +00:00
|
|
|
|
|
|
|
// try loading a component and releasing it to see if it leaks
|
2012-07-30 14:20:58 +00:00
|
|
|
if (argc > 1 && argv[1] != nullptr) {
|
1999-09-28 18:01:47 +00:00
|
|
|
char* cidStr = argv[1];
|
2012-07-30 14:20:58 +00:00
|
|
|
nsISupports* obj = nullptr;
|
1999-09-28 18:01:47 +00:00
|
|
|
if (cidStr[0] == '{') {
|
|
|
|
nsCID cid;
|
|
|
|
cid.Parse(cidStr);
|
2004-11-01 18:50:36 +00:00
|
|
|
rv = CallCreateInstance(cid, &obj);
|
1999-09-28 18:01:47 +00:00
|
|
|
}
|
|
|
|
else {
|
2000-09-13 23:57:52 +00:00
|
|
|
// contractID case:
|
2004-11-01 18:50:36 +00:00
|
|
|
rv = CallCreateInstance(cidStr, &obj);
|
1999-09-28 18:01:47 +00:00
|
|
|
}
|
1999-07-28 08:28:10 +00:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
1999-09-28 18:01:47 +00:00
|
|
|
printf("Successfully created %s\n", cidStr);
|
1999-07-28 08:28:10 +00:00
|
|
|
NS_RELEASE(obj);
|
|
|
|
}
|
|
|
|
else {
|
1999-09-28 18:01:47 +00:00
|
|
|
printf("Failed to create %s (%x)\n", cidStr, rv);
|
1999-07-28 08:28:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-07-28 08:01:55 +00:00
|
|
|
rv = NS_ShutdownXPCOM(servMgr);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");
|
|
|
|
}
|