if (! functions->unregisterExitRoutine) {
if (! functions->getDebug) { PR_UnloadLibrary(xpcomLib); return NS_ERROR_FAILURE; }  functions->getTraceRefcnt = (GetTraceRefcntFunc) PR_FindSymbol(xpcomLib, "NS_GetTraceRefcnt"); if (! functions->getTraceRefcnt) {
NS_GetFrozenFunctions(XPCOMFunctions *functions, const char* libraryPath){    if (!functions)        return NS_ERROR_OUT_OF_MEMORY;    if (functions->version != XPCOM_GLUE_VERSION)        return NS_ERROR_FAILURE;    PRLibrary *xpcomLib = nsnull;    xpcomLib = PR_LoadLibrary(libraryPath);    if (!xpcomLib)        return NS_ERROR_FAILURE;    functions->init = (InitFunc) PR_FindSymbol(xpcomLib, "NS_InitXPCOM2");    if (! functions->init) {        PR_UnloadLibrary(xpcomLib);        return NS_ERROR_FAILURE;    }    functions->shutdown = (ShutdownFunc) PR_FindSymbol(xpcomLib, "NS_ShutdownXPCOM");    if (! functions->shutdown) {        PR_UnloadLibrary(xpcomLib);        return NS_ERROR_FAILURE;    }    functions->getServiceManager = (GetServiceManagerFunc) PR_FindSymbol(xpcomLib, "NS_GetServiceManager");    if (! functions->getServiceManager) {        PR_UnloadLibrary(xpcomLib);        return NS_ERROR_FAILURE;    }    functions->getComponentManager = (GetComponentManagerFunc) PR_FindSymbol(xpcomLib, "NS_GetComponentManager");    if (! functions->getComponentManager) {        PR_UnloadLibrary(xpcomLib);        return NS_ERROR_FAILURE;    }    functions->getComponentRegistrar = (GetComponentRegistrarFunc) PR_FindSymbol(xpcomLib, "NS_GetComponentRegistrar");    if (! functions->getComponentRegistrar) {        PR_UnloadLibrary(xpcomLib);        return NS_ERROR_FAILURE;    }    functions->getMemoryManager = (GetMemoryManagerFunc) PR_FindSymbol(xpcomLib, "NS_GetMemoryManager");    if (! functions->getMemoryManager) {        PR_UnloadLibrary(xpcomLib);        return NS_ERROR_FAILURE;    }    functions->newLocalFile = (NewLocalFileFunc) PR_FindSymbol(xpcomLib, "NS_NewLocalFile");    if (! functions->newLocalFile) {        PR_UnloadLibrary(xpcomLib);        return NS_ERROR_FAILURE;    }    functions->newNativeLocalFile = (NewNativeLocalFileFunc)PR_FindSymbol(xpcomLib, "NS_NewNativeLocalFile");    if (! functions->newNativeLocalFile) {        PR_UnloadLibrary(xpcomLib);        return NS_ERROR_FAILURE;    }    functions->registerExitRoutine = (RegisterXPCOMExitRoutineFunc) PR_FindSymbol(xpcomLib, "NS_RegisterXPCOMExitRoutine");    if (! functions->registerExitRoutine) {        PR_UnloadLibrary(xpcomLib);        return NS_ERROR_FAILURE;    }    functions->unregisterExitRoutine = (UnregisterXPCOMExitRoutineFunc) PR_FindSymbol(xpcomLib, "NS_UnregisterXPCOMExitRoutine");    if (! functions->unregisterExitRoutine) {        PR_UnloadLibrary(xpcomLib);        return NS_ERROR_FAILURE;    }    functions->getDebug = (GetDebugFunc) PR_FindSymbol(xpcomLib, "NS_GetDebug");    if (! functions->unregisterExitRoutine) {        PR_UnloadLibrary(xpcomLib);        return NS_ERROR_FAILURE;    }    PR_UnloadLibrary(xpcomLib); // the library is refcnt'ed above by the caller.    xpcomLib = nsnull;    return NS_OK;}