diff --git a/layout/mathml/content/src/nsMathMLOperators.cpp b/layout/mathml/content/src/nsMathMLOperators.cpp index bc4802d4f64..450ea897095 100644 --- a/layout/mathml/content/src/nsMathMLOperators.cpp +++ b/layout/mathml/content/src/nsMathMLOperators.cpp @@ -382,27 +382,32 @@ InitGlobals() rv = InitOperators(); } } - if (NS_FAILED(rv)) { - if (gInvariantCharArray) { - delete gInvariantCharArray; - gInvariantCharArray = nsnull; - } - if (gOperatorArray) { - delete[] gOperatorArray; - gOperatorArray = nsnull; - } - if (gStretchyOperatorArray) { - delete gStretchyOperatorArray; - gStretchyOperatorArray = nsnull; - } - if (gOperatorTable) { - delete gOperatorTable; - gOperatorTable = nsnull; - } - } + if (NS_FAILED(rv)) + nsMathMLOperators::CleanUp(); return rv; } +void +nsMathMLOperators::CleanUp() +{ + if (gInvariantCharArray) { + delete gInvariantCharArray; + gInvariantCharArray = nsnull; + } + if (gOperatorArray) { + delete[] gOperatorArray; + gOperatorArray = nsnull; + } + if (gStretchyOperatorArray) { + delete gStretchyOperatorArray; + gStretchyOperatorArray = nsnull; + } + if (gOperatorTable) { + delete gOperatorTable; + gOperatorTable = nsnull; + } +} + void nsMathMLOperators::AddRefTable(void) { @@ -413,18 +418,7 @@ void nsMathMLOperators::ReleaseTable(void) { if (0 == --gTableRefCount) { - if (gOperatorArray) { - delete[] gOperatorArray; - gOperatorArray = nsnull; - } - if (gStretchyOperatorArray) { - delete gStretchyOperatorArray; - gStretchyOperatorArray = nsnull; - } - if (gOperatorTable) { - delete gOperatorTable; - gOperatorTable = nsnull; - } + CleanUp(); } } diff --git a/layout/mathml/content/src/nsMathMLOperators.h b/layout/mathml/content/src/nsMathMLOperators.h index 1e33e9938b7..1f1889b2719 100644 --- a/layout/mathml/content/src/nsMathMLOperators.h +++ b/layout/mathml/content/src/nsMathMLOperators.h @@ -84,6 +84,7 @@ class nsMathMLOperators { public: static void AddRefTable(void); static void ReleaseTable(void); + static void CleanUp(); // LookupOperator: // Given the string value of an operator and its form (last two bits of flags),