xpcom/tests/TestShutdown.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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 {
    12     nsresult rv;
    13     nsIServiceManager* servMgr;
    14     rv = NS_InitXPCOM2(&servMgr, nullptr, nullptr);
    15     NS_ASSERTION(NS_SUCCEEDED(rv), "NS_InitXPCOM failed");
    17     // try loading a component and releasing it to see if it leaks
    18     if (argc > 1 && argv[1] != nullptr) {
    19         char* cidStr = argv[1];
    20         nsISupports* obj = nullptr;
    21         if (cidStr[0] == '{') {
    22             nsCID cid;
    23             cid.Parse(cidStr);
    24             rv = CallCreateInstance(cid, &obj);
    25         }
    26         else {
    27             // contractID case:
    28             rv = CallCreateInstance(cidStr, &obj);
    29         }
    30         if (NS_SUCCEEDED(rv)) {
    31             printf("Successfully created %s\n", cidStr);
    32             NS_RELEASE(obj);
    33         }
    34         else {
    35             printf("Failed to create %s (%x)\n", cidStr, rv);
    36         }
    37     }
    39     rv = NS_ShutdownXPCOM(servMgr);
    40     NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");
    41 }

mercurial