From e84b06a56d87ea33db1c2bcff139dbadcd17cd90 Mon Sep 17 00:00:00 2001 From: "shaver@netscape.com" Date: Thu, 9 Sep 1999 00:48:30 +0000 Subject: [PATCH] fix memory leaks (eep) and add some debugging noise for myself --- xpcom/components/nsComponentManager.cpp | 16 ++++++++++++++-- xpcom/components/nsComponentManager.h | 14 +++++++++----- xpcom/components/nsNativeComponentLoader.cpp | 3 +++ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/xpcom/components/nsComponentManager.cpp b/xpcom/components/nsComponentManager.cpp index fc67b1ac5598..9d1101a71e8c 100644 --- a/xpcom/components/nsComponentManager.cpp +++ b/xpcom/components/nsComponentManager.cpp @@ -106,8 +106,8 @@ nsFactoryEntry::nsFactoryEntry(const nsCID &aClass, : cid(aClass), factory(nsnull), loader(aLoader) { loader = aLoader; - type = nsCRT::strdup(aType); - location = nsCRT::strdup(aLocation); + type = aType; + location = aLocation; } nsFactoryEntry::nsFactoryEntry(const nsCID &aClass, nsIFactory *aFactory) @@ -674,6 +674,9 @@ nsComponentManagerImpl::PlatformFind(const nsCID &aCID, nsFactoryEntry* *result) if (NS_FAILED(rv)) return rv; +#ifdef DEBUG_shaver + fprintf(stderr, "NEW FACTORYENTRY(%s,%s)\n", library, componentType); +#endif nsFactoryEntry *res = new nsFactoryEntry(aCID, library, componentType, loader); if (res == NULL) @@ -783,6 +786,9 @@ nsresult nsComponentManagerImpl::PlatformPrePopulateRegistry() &componentType))) continue; +#ifdef DEBUG_shaver + fprintf(stderr, "NEW FACTORYENTRY(%s,%s)\n", library, componentType); +#endif nsFactoryEntry* entry = /* hand off componentType and library to factory */ new nsFactoryEntry(aClass, library, componentType, @@ -1389,6 +1395,9 @@ nsComponentManagerImpl::RegisterFactory(const nsCID &aClass, return NS_ERROR_FACTORY_EXISTS; } +#ifdef DEBUG_shaver + fprintf(stderr, "NEW FACTORYENTRY(Factory,%s)\n", aProgID); +#endif nsFactoryEntry *newEntry = new nsFactoryEntry(aClass, aFactory); if (newEntry == NULL) return NS_ERROR_OUT_OF_MEMORY; @@ -1556,6 +1565,9 @@ nsComponentManagerImpl::RegisterComponentCommon(const nsCID &aClass, goto out; } +#ifdef DEBUG_shaver + fprintf(stderr, "NEW FACTORYENTRY(%s,%s)\n", aRegistryName, aType); +#endif /* hand off aRegistryName to entry */ newEntry = new nsFactoryEntry(aClass, aRegistryName, nsCRT::strdup(aType), diff --git a/xpcom/components/nsComponentManager.h b/xpcom/components/nsComponentManager.h index b2284bdaa398..26d78b4d5adc 100644 --- a/xpcom/components/nsComponentManager.h +++ b/xpcom/components/nsComponentManager.h @@ -185,21 +185,25 @@ public: nsresult rv; if (!loader.get()) { +#ifdef DEBUG_shaver + fprintf(stderr, "NFE: getting loader for %s\n", type); +#endif rv = mgr->GetLoaderForType(type, getter_AddRefs(loader)); if(NS_FAILED(rv)) return rv; } + +#ifdef DEBUG_shaver + char *cidStr = cid.ToString(); + fprintf(stderr, "NFE: getting factory for %s \n", cidStr); + delete [] cidStr; +#endif rv = loader->GetFactory(cid, location, type, aFactory); if (NS_SUCCEEDED(rv)) factory = do_QueryInterface(*aFactory); return rv; } -#if 0 /* unused? */ - nsresult Init(nsHashtable* dllHashtable, const nsCID &aClass, const char *aLibrary, - PRTime lastModTime, PRUint32 fileSize); -#endif - nsCID cid; char *location; nsCOMPtr factory; diff --git a/xpcom/components/nsNativeComponentLoader.cpp b/xpcom/components/nsNativeComponentLoader.cpp index aa816ab81d72..6d7b1b659988 100644 --- a/xpcom/components/nsNativeComponentLoader.cpp +++ b/xpcom/components/nsNativeComponentLoader.cpp @@ -65,6 +65,9 @@ private: nsNativeComponentLoader::nsNativeComponentLoader() : mRegistry(nsnull), mCompMgr(nsnull), mDllStore(nsnull) { +#ifdef DEBUG_shaver + fprintf(stderr, "NEW NATIVECOMPONENTLOADER\n"); +#endif NS_INIT_REFCNT(); }