Allow atom table to be purged during shtudown

This commit is contained in:
kipp%netscape.com 1999-09-30 21:40:00 +00:00
parent 556d538c8f
commit 4f9c341b0c
2 changed files with 34 additions and 0 deletions

View File

@ -28,6 +28,38 @@
static nsrefcnt gAtoms; static nsrefcnt gAtoms;
static struct PLHashTable* gAtomHashTable; static struct PLHashTable* gAtomHashTable;
#if defined(DEBUG_kipp) && (defined(XP_UNIX) || defined(XP_PC))
static PRIntn
DumpAtomLeaks(PLHashEntry *he, PRIntn index, void *arg)
{
AtomImpl* atom = (AtomImpl*) he->value;
if (atom) {
nsAutoString tmp;
atom->ToString(tmp);
fputs(tmp, stdout);
fputs("\n", stdout);
}
return HT_ENUMERATE_NEXT;
}
#endif
NS_COM void NS_PurgeAtomTable(void)
{
if (gAtomHashTable) {
#if defined(DEBUG_kipp) && (defined(XP_UNIX) || defined(XP_PC))
if (0 != gAtoms) {
printf("*** leaking %d atoms\n", gAtoms);
if (getenv("MOZ_DUMP_ATOM_LEAKS")) {
printf("*** leaked atoms:\n");
PL_HashTableEnumerateEntries(gAtomHashTable, DumpAtomLeaks, 0);
}
}
#endif
PL_HashTableDestroy(gAtomHashTable);
gAtomHashTable = nsnull;
}
}
AtomImpl::AtomImpl() AtomImpl::AtomImpl()
{ {
NS_INIT_REFCNT(); NS_INIT_REFCNT();

View File

@ -77,4 +77,6 @@ extern NS_COM nsIAtom* NS_NewAtom(const nsString& aString);
*/ */
extern NS_COM nsrefcnt NS_GetNumberOfAtoms(void); extern NS_COM nsrefcnt NS_GetNumberOfAtoms(void);
extern NS_COM void NS_PurgeAtomTable(void);
%} %}