Memory audit of code in src directory. Found and fixed some leaks.
Declaring this directory memory clean. M src/Pluglet.cpp M src/Pluglet.h - use do_GetService instead of servman->GetServiceByContractID - do not keep a reference to plugletEngine as an ivar M src/PlugletFactory.cpp M src/PlugletFactory.h - use nsnull instead of NULL - do not keep a reference to plugletEngine as an ivar - use PL_strdup and PL_strfree to duplicate and free strings M src/PlugletsDir.cpp - use PL_strdup and PL_strfree to duplicate and free strings git-svn-id: svn://10.0.0.236/trunk@215043 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -28,13 +28,15 @@
|
||||
static PRIntn DeleteEntryEnumerator(PLHashEntry *he, PRIntn i, void *arg)
|
||||
{
|
||||
PLHashTable *hash = (PLHashTable *) arg;
|
||||
PL_HashTableRemove(hash, he->key);
|
||||
|
||||
void *key = (void *) he->key;
|
||||
nsMemory::Free(key);
|
||||
char *key = (char *) he->key;
|
||||
|
||||
PL_strfree(key);
|
||||
|
||||
PlugletFactory *toDelete = (PlugletFactory *) he->value;
|
||||
delete toDelete;
|
||||
|
||||
PL_HashTableRemove(hash, he->key);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -102,14 +104,21 @@ nsresult PlugletsDir::LoadPluglets() {
|
||||
mimeType = nsnull;
|
||||
rv = plugletFactory->GetMIMEDescription(&mimeType);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
const char *key = PL_strdup(mimeType);
|
||||
printf("debug: edburns: key: %s address: %p\n",
|
||||
key, key);
|
||||
PLHashEntry *entry =
|
||||
PL_HashTableAdd(mMimeTypeToPlugletFacoryHash,
|
||||
(const void *) PL_strdup(mimeType),
|
||||
(const void *) key,
|
||||
plugletFactory);
|
||||
rv = (nsnull != entry) ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (path) {
|
||||
PL_strfree(path);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user