Skip to content

Commit 1308b7e

Browse files
author
warren%netscape.com
committed
Added ability to instantiate a component to test it for leaks.
1 parent 14ca756 commit 1308b7e

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

xpcom/tests/TestShutdown.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,30 @@
1818

1919
#include "nsIServiceManager.h"
2020

21-
// Gee this seems simple! It's for testing for memory leaks.
21+
// Gee this seems simple! It's for testing for memory leaks with Purify.
2222

23-
void main()
23+
void main(int argc, char* argv[])
2424
{
2525
nsresult rv;
2626
nsIServiceManager* servMgr;
2727
rv = NS_InitXPCOM(&servMgr);
2828
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_InitXPCOM failed");
29+
30+
// try loading a component and releasing it to see if it leaks
31+
if (argc > 1 && argv[1] != nsnull) {
32+
nsISupports* obj = nsnull;
33+
rv = nsComponentManager::CreateInstance(argv[1], nsnull,
34+
nsCOMTypeInfo<nsISupports>::GetIID(),
35+
(void**)&obj);
36+
if (NS_SUCCEEDED(rv)) {
37+
printf("Successfully created %s\n", argv[1]);
38+
NS_RELEASE(obj);
39+
}
40+
else {
41+
printf("Failed to create %s (%x)\n", argv[1], rv);
42+
}
43+
}
44+
2945
rv = NS_ShutdownXPCOM(servMgr);
3046
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");
3147
NS_RELEASE(servMgr);

0 commit comments

Comments
 (0)