fix memory leaks (eep) and add some debugging noise for myself

This commit is contained in:
shaver%netscape.com 1999-09-09 00:48:30 +00:00
parent bf77668740
commit a131f8079e
3 changed files with 26 additions and 7 deletions

View File

@ -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),

View File

@ -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<nsIFactory> factory;

View File

@ -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();
}