Bug 1217307 - Remove some unnecessary null checks in dom/xslt/. r=njn

This commit is contained in:
Birunthan Mohanathas 2015-11-19 09:13:49 +02:00
parent 1df11ed177
commit 8308d650f3
24 changed files with 18 additions and 315 deletions

View File

@ -65,8 +65,6 @@ nsresult txList::insertAfter(void* objPtr, ListItem* refItem)
nsresult txList::insertBefore(void* objPtr, ListItem* refItem)
{
ListItem* item = new ListItem;
NS_ENSURE_TRUE(item, NS_ERROR_OUT_OF_MEMORY);
item->objPtr = objPtr;
item->nextItem = 0;
item->prevItem = 0;

View File

@ -361,9 +361,6 @@ txExprLexer::parse(const nsASingleFragmentString& aPattern)
// add a endToken to the list
newToken = new Token(end, end, Token::END);
if (!newToken) {
return NS_ERROR_OUT_OF_MEMORY;
}
addToken(newToken);
return NS_OK;

View File

@ -121,8 +121,6 @@ txExprParser::createAVT(const nsSubstring& aAttrValue,
else {
if (!concat) {
concat = new txCoreFunctionCall(txCoreFunctionCall::CONCAT);
NS_ENSURE_TRUE(concat, NS_ERROR_OUT_OF_MEMORY);
rv = concat->addParam(expr.forget());
expr = concat;
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -353,7 +353,6 @@ txNodeSet::mark(int32_t aIndex)
if (!mMarks) {
int32_t length = size();
mMarks = new bool[length];
NS_ENSURE_TRUE(mMarks, NS_ERROR_OUT_OF_MEMORY);
memset(mMarks, 0, length * sizeof(bool));
}
if (mDirection == kForward) {

View File

@ -26,8 +26,7 @@ txNodeSetAdaptor::Init()
if (!mValue) {
mValue = new txNodeSet(nullptr);
}
return mValue ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
NS_IMETHODIMP

View File

@ -77,7 +77,6 @@ txResultRecycler::getStringResult(StringResult** aResult)
{
if (mStringResults.isEmpty()) {
*aResult = new StringResult(this);
NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
}
else {
*aResult = static_cast<StringResult*>(mStringResults.pop());
@ -95,7 +94,6 @@ txResultRecycler::getStringResult(const nsAString& aValue,
{
if (mStringResults.isEmpty()) {
*aResult = new StringResult(aValue, this);
NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
}
else {
StringResult* strRes =
@ -121,7 +119,6 @@ txResultRecycler::getNodeSet(txNodeSet** aResult)
{
if (mNodeSetResults.isEmpty()) {
*aResult = new txNodeSet(this);
NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
}
else {
*aResult = static_cast<txNodeSet*>(mNodeSetResults.pop());
@ -137,7 +134,6 @@ txResultRecycler::getNodeSet(txNodeSet* aNodeSet, txNodeSet** aResult)
{
if (mNodeSetResults.isEmpty()) {
*aResult = new txNodeSet(*aNodeSet, this);
NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
}
else {
*aResult = static_cast<txNodeSet*>(mNodeSetResults.pop());
@ -154,7 +150,6 @@ txResultRecycler::getNodeSet(const txXPathNode& aNode, txAExprResult** aResult)
{
if (mNodeSetResults.isEmpty()) {
*aResult = new txNodeSet(aNode, this);
NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
}
else {
txNodeSet* nodes = static_cast<txNodeSet*>(mNodeSetResults.pop());
@ -172,7 +167,6 @@ txResultRecycler::getNumberResult(double aValue, txAExprResult** aResult)
{
if (mNumberResults.isEmpty()) {
*aResult = new NumberResult(aValue, this);
NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
}
else {
NumberResult* numRes =

View File

@ -256,8 +256,7 @@ TX_ResolveFunctionCallXPCOM(const nsCString &aContractID, int32_t aNamespaceID,
aName,
#endif
aState);
return *aFunction ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
txArgumentType
@ -340,10 +339,6 @@ txParamArrayHolder::Init(uint8_t aCount)
{
mCount = aCount;
mArray = new nsXPTCVariant[mCount];
if (!mArray) {
return false;
}
memset(mArray, 0, mCount * sizeof(nsXPTCVariant));
return true;
@ -389,9 +384,6 @@ txXPCOMExtensionFunctionCall::evaluate(txIEvalContext* aContext,
// Create context wrapper.
context = new txFunctionEvaluationContext(aContext, mState);
if (!context) {
return NS_ERROR_OUT_OF_MEMORY;
}
nsXPTCVariant &invokeParam = invokeParams[0];
invokeParam.type = paramInfo.GetType();
@ -512,10 +504,6 @@ txXPCOMExtensionFunctionCall::evaluate(txIEvalContext* aContext,
returnParam.type = returnInfo.GetType();
if (returnType == eSTRING) {
nsString *value = new nsString();
if (!value) {
return NS_ERROR_FAILURE;
}
returnParam.SetValNeedsCleanup();
returnParam.val.p = value;
}

View File

@ -133,8 +133,6 @@ txXPathOptimizer::optimizeStep(Expr* aInExpr, Expr** aOutExpr)
*aOutExpr = new txNamedAttributeStep(nameTest->mNamespace,
nameTest->mPrefix,
nameTest->mLocalName);
NS_ENSURE_TRUE(*aOutExpr, NS_ERROR_OUT_OF_MEMORY);
return NS_OK; // return since we no longer have a step-object.
}
}
@ -145,8 +143,6 @@ txXPathOptimizer::optimizeStep(Expr* aInExpr, Expr** aOutExpr)
!pred->canReturnType(Expr::NUMBER_RESULT) &&
!pred->isSensitiveTo(Expr::NODESET_CONTEXT)) {
txNodeTest* predTest = new txPredicatedNodeTest(step->getNodeTest(), pred);
NS_ENSURE_TRUE(predTest, NS_ERROR_OUT_OF_MEMORY);
step->dropFirst();
step->setNodeTest(predTest);
}
@ -252,8 +248,6 @@ txXPathOptimizer::optimizeUnion(Expr* aInExpr, Expr** aOutExpr)
// Create a txUnionNodeTest if needed
if (!unionTest) {
nsAutoPtr<txNodeTest> owner(unionTest = new txUnionNodeTest);
NS_ENSURE_TRUE(unionTest, NS_ERROR_OUT_OF_MEMORY);
rv = unionTest->addNodeTest(currentStep->getNodeTest());
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -204,8 +204,6 @@ txBufferingHandler::attribute(nsIAtom* aPrefix, nsIAtom* aLocalName,
new txAttributeAtomTransaction(aPrefix, aLocalName,
aLowercaseLocalName, aNsID,
aValue);
NS_ENSURE_TRUE(transaction, NS_ERROR_OUT_OF_MEMORY);
return mBuffer->addTransaction(transaction);
}
@ -222,8 +220,6 @@ txBufferingHandler::attribute(nsIAtom* aPrefix, const nsSubstring& aLocalName,
txOutputTransaction* transaction =
new txAttributeTransaction(aPrefix, aLocalName, aNsID, aValue);
NS_ENSURE_TRUE(transaction, NS_ERROR_OUT_OF_MEMORY);
return mBuffer->addTransaction(transaction);
}
@ -247,8 +243,6 @@ txBufferingHandler::characters(const nsSubstring& aData, bool aDOE)
}
transaction = new txCharacterTransaction(type, aData.Length());
NS_ENSURE_TRUE(transaction, NS_ERROR_OUT_OF_MEMORY);
mBuffer->mStringValue.Append(aData);
return mBuffer->addTransaction(transaction);
}
@ -261,8 +255,6 @@ txBufferingHandler::comment(const nsString& aData)
mCanAddAttribute = false;
txOutputTransaction* transaction = new txCommentTransaction(aData);
NS_ENSURE_TRUE(transaction, NS_ERROR_OUT_OF_MEMORY);
return mBuffer->addTransaction(transaction);
}
@ -273,8 +265,6 @@ txBufferingHandler::endDocument(nsresult aResult)
txOutputTransaction* transaction =
new txOutputTransaction(txOutputTransaction::eEndDocumentTransaction);
NS_ENSURE_TRUE(transaction, NS_ERROR_OUT_OF_MEMORY);
return mBuffer->addTransaction(transaction);
}
@ -287,8 +277,6 @@ txBufferingHandler::endElement()
txOutputTransaction* transaction =
new txOutputTransaction(txOutputTransaction::eEndElementTransaction);
NS_ENSURE_TRUE(transaction, NS_ERROR_OUT_OF_MEMORY);
return mBuffer->addTransaction(transaction);
}
@ -302,8 +290,6 @@ txBufferingHandler::processingInstruction(const nsString& aTarget,
txOutputTransaction* transaction =
new txPITransaction(aTarget, aData);
NS_ENSURE_TRUE(transaction, NS_ERROR_OUT_OF_MEMORY);
return mBuffer->addTransaction(transaction);
}
@ -314,8 +300,6 @@ txBufferingHandler::startDocument()
txOutputTransaction* transaction =
new txOutputTransaction(txOutputTransaction::eStartDocumentTransaction);
NS_ENSURE_TRUE(transaction, NS_ERROR_OUT_OF_MEMORY);
return mBuffer->addTransaction(transaction);
}
@ -331,8 +315,6 @@ txBufferingHandler::startElement(nsIAtom* aPrefix, nsIAtom* aLocalName,
txOutputTransaction* transaction =
new txStartElementAtomTransaction(aPrefix, aLocalName,
aLowercaseLocalName, aNsID);
NS_ENSURE_TRUE(transaction, NS_ERROR_OUT_OF_MEMORY);
return mBuffer->addTransaction(transaction);
}
@ -347,8 +329,6 @@ txBufferingHandler::startElement(nsIAtom* aPrefix,
txOutputTransaction* transaction =
new txStartElementTransaction(aPrefix, aLocalName, aNsID);
NS_ENSURE_TRUE(transaction, NS_ERROR_OUT_OF_MEMORY);
return mBuffer->addTransaction(transaction);
}

View File

@ -708,8 +708,7 @@ TX_ConstructEXSLTFunction(nsIAtom *aName,
if (aName == *desc.mName && aNamespaceID == desc.mNamespaceID) {
*aResult = new txEXSLTFunctionCall(
static_cast<txEXSLTFunctionCall::eType>(i));
return *aResult ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
}

View File

@ -103,8 +103,6 @@ txExecutionState::init(const txXPathNode& aNode,
// Set up initial context
mEvalContext = new txSingleNodeContext(aNode, this);
NS_ENSURE_TRUE(mEvalContext, NS_ERROR_OUT_OF_MEMORY);
mInitialEvalContext = mEvalContext;
// Set up output and result-handler
@ -129,7 +127,6 @@ txExecutionState::init(const txXPathNode& aNode,
// The actual value here doesn't really matter since noone should use this
// value. But lets put something errorlike in just in case
mGlobalVarPlaceholderValue = new StringResult(NS_LITERAL_STRING("Error"), nullptr);
NS_ENSURE_TRUE(mGlobalVarPlaceholderValue, NS_ERROR_OUT_OF_MEMORY);
// Initiate first instruction. This has to be done last since findTemplate
// might use us.
@ -482,7 +479,6 @@ txExecutionState::bindVariable(const txExpandedName& aName,
{
if (!mLocalVariables) {
mLocalVariables = new txVariableMap;
NS_ENSURE_TRUE(mLocalVariables, NS_ERROR_OUT_OF_MEMORY);
}
return mLocalVariables->bindVariable(aName, aValue);
}

View File

@ -275,8 +275,6 @@ txFormatNumberFunctionCall::evaluate(txIEvalContext* aContext,
bufsize = 1 + 30;
char* buf = new char[bufsize];
NS_ENSURE_TRUE(buf, NS_ERROR_OUT_OF_MEMORY);
int bufIntDigits, sign;
char* endp;
PR_dtoa(value, 0, 0, &bufIntDigits, &sign, &endp, buf, bufsize-1);

View File

@ -699,8 +699,6 @@ nsresult
txPushRTFHandler::execute(txExecutionState& aEs)
{
txAXMLEventHandler* handler = new txRtfHandler;
NS_ENSURE_TRUE(handler, NS_ERROR_OUT_OF_MEMORY);
nsresult rv = aEs.pushResultHandler(handler);
if (NS_FAILED(rv)) {
delete handler;
@ -719,8 +717,6 @@ nsresult
txPushStringHandler::execute(txExecutionState& aEs)
{
txAXMLEventHandler* handler = new txTextHandler(mOnlyText);
NS_ENSURE_TRUE(handler, NS_ERROR_OUT_OF_MEMORY);
nsresult rv = aEs.pushResultHandler(handler);
if (NS_FAILED(rv)) {
delete handler;

View File

@ -529,8 +529,6 @@ handleNode(nsINode* aNode, txStylesheetCompiler* aCompiler)
nsAutoArrayPtr<txStylesheetAttr> atts;
if (attsCount > 0) {
atts = new txStylesheetAttr[attsCount];
NS_ENSURE_TRUE(atts, NS_ERROR_OUT_OF_MEMORY);
uint32_t counter;
for (counter = 0; counter < attsCount; ++counter) {
txStylesheetAttr& att = atts[counter];

View File

@ -516,7 +516,6 @@ txMozillaXSLTProcessor::AddXSLTParam(const nsString& aName,
}
else {
value = new StringResult(aValue, nullptr);
NS_ENSURE_TRUE(value, NS_ERROR_OUT_OF_MEMORY);
}
nsCOMPtr<nsIAtom> name = do_GetAtom(aName);
@ -574,12 +573,7 @@ txMozillaXSLTProcessor::DoTransform()
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIRunnable> event = new nsTransformBlockerEvent(this);
if (!event) {
return NS_ERROR_OUT_OF_MEMORY;
}
document->BlockOnload();
rv = NS_DispatchToCurrentThread(event);
if (NS_FAILED(rv)) {
// XXX Maybe we should just display the source document in this case?
@ -956,8 +950,6 @@ txMozillaXSLTProcessor::SetParameter(const nsAString & aNamespaceURI,
}
var = new txVariable(value);
NS_ENSURE_TRUE(var, NS_ERROR_OUT_OF_MEMORY);
return mVariables.add(varName, var);
}
@ -1414,8 +1406,6 @@ txVariable::Convert(nsIVariant *aValue, txAExprResult** aResult)
NS_ENSURE_SUCCESS(rv, rv);
*aResult = new NumberResult(value, nullptr);
NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
NS_ADDREF(*aResult);
return NS_OK;
@ -1429,8 +1419,6 @@ txVariable::Convert(nsIVariant *aValue, txAExprResult** aResult)
NS_ENSURE_SUCCESS(rv, rv);
*aResult = new BooleanResult(value);
NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
NS_ADDREF(*aResult);
return NS_OK;
@ -1453,8 +1441,6 @@ txVariable::Convert(nsIVariant *aValue, txAExprResult** aResult)
NS_ENSURE_SUCCESS(rv, rv);
*aResult = new StringResult(value, nullptr);
NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
NS_ADDREF(*aResult);
return NS_OK;
@ -1537,10 +1523,6 @@ txVariable::Convert(nsIVariant *aValue, txAExprResult** aResult)
NS_ENSURE_TRUE(value.init(cx, str), NS_ERROR_FAILURE);
*aResult = new StringResult(value, nullptr);
if (!*aResult) {
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(*aResult);
return NS_OK;

View File

@ -37,7 +37,6 @@ txNodeSorter::addSortElement(Expr* aSelectExpr, Expr* aLangExpr,
Expr* aCaseOrderExpr, txIEvalContext* aContext)
{
nsAutoPtr<SortKey> key(new SortKey);
NS_ENSURE_TRUE(key, NS_ERROR_OUT_OF_MEMORY);
nsresult rv = NS_OK;
// Select
@ -98,12 +97,10 @@ txNodeSorter::addSortElement(Expr* aSelectExpr, Expr* aLangExpr,
key->mComparator = new txResultStringComparator(ascending,
upperFirst,
lang);
NS_ENSURE_TRUE(key->mComparator, NS_ERROR_OUT_OF_MEMORY);
}
else if (TX_StringEqualsAtom(dataType, nsGkAtoms::number)) {
// Number comparator
key->mComparator = new txResultNumberComparator(ascending);
NS_ENSURE_TRUE(key->mComparator, NS_ERROR_OUT_OF_MEMORY);
}
else {
// XXX ErrorReport: unknown data-type

View File

@ -63,10 +63,6 @@ nsresult txPatternParser::createUnionPattern(txExprLexer& aLexer,
}
txUnionPattern* unionPattern = new txUnionPattern();
if (!unionPattern) {
delete locPath;
return NS_ERROR_OUT_OF_MEMORY;
}
rv = unionPattern->addPattern(locPath);
#if 0 // XXX addPattern can't fail yet, it doesn't check for mem
if (NS_FAILED(rv)) {
@ -127,8 +123,7 @@ nsresult txPatternParser::createLocPathPattern(txExprLexer& aLexer,
if (aLexer.peek()->mType == Token::END ||
aLexer.peek()->mType == Token::UNION_OP) {
aPattern = new txRootPattern();
return aPattern ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
break;
case Token::FUNCTION_NAME_AND_PAREN:
@ -163,19 +158,8 @@ nsresult txPatternParser::createLocPathPattern(txExprLexer& aLexer,
}
pathPattern = new txLocPathPattern();
if (!pathPattern) {
delete stepPattern;
return NS_ERROR_OUT_OF_MEMORY;
}
if (isAbsolute) {
txRootPattern* root = new txRootPattern();
if (!root) {
delete stepPattern;
delete pathPattern;
return NS_ERROR_OUT_OF_MEMORY;
}
#ifdef TX_TO_STRING
root->setSerialize(false);
#endif
@ -229,7 +213,7 @@ nsresult txPatternParser::createIdPattern(txExprLexer& aLexer,
if (aLexer.nextToken()->mType != Token::R_PAREN)
return NS_ERROR_XPATH_PARSE_FAILURE;
aPattern = new txIdPattern(value);
return aPattern ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
nsresult txPatternParser::createKeyPattern(txExprLexer& aLexer,
@ -263,8 +247,7 @@ nsresult txPatternParser::createKeyPattern(txExprLexer& aLexer,
return rv;
aPattern = new txKeyPattern(prefix, localName, namespaceID, value);
return aPattern ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
nsresult txPatternParser::createStepPattern(txExprLexer& aLexer,
@ -308,9 +291,6 @@ nsresult txPatternParser::createStepPattern(txExprLexer& aLexer,
(uint16_t)txXPathNodeType::ATTRIBUTE_NODE :
(uint16_t)txXPathNodeType::ELEMENT_NODE;
nodeTest = new txNameTest(prefix, lName, nspace, nodeType);
if (!nodeTest) {
return NS_ERROR_OUT_OF_MEMORY;
}
}
else {
rv = createNodeTypeTest(aLexer, &nodeTest);
@ -318,11 +298,6 @@ nsresult txPatternParser::createStepPattern(txExprLexer& aLexer,
}
nsAutoPtr<txStepPattern> step(new txStepPattern(nodeTest, isAttr));
if (!step) {
delete nodeTest;
return NS_ERROR_OUT_OF_MEMORY;
}
rv = parsePredicates(step, aLexer, aContext);
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -62,10 +62,7 @@ nsresult
txRtfHandler::getAsRTF(txAExprResult** aResult)
{
*aResult = new txResultTreeFragment(Move(mBuffer));
NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
NS_ADDREF(*aResult);
return NS_OK;
}

View File

@ -28,59 +28,40 @@ nsresult
txStylesheet::init()
{
mRootFrame = new ImportFrame;
NS_ENSURE_TRUE(mRootFrame, NS_ERROR_OUT_OF_MEMORY);
// Create default templates
// element/root template
mContainerTemplate = new txPushParams;
NS_ENSURE_TRUE(mContainerTemplate, NS_ERROR_OUT_OF_MEMORY);
nsAutoPtr<txNodeTest> nt(new txNodeTypeTest(txNodeTypeTest::NODE_TYPE));
NS_ENSURE_TRUE(nt, NS_ERROR_OUT_OF_MEMORY);
nsAutoPtr<Expr> nodeExpr(new LocationStep(nt, LocationStep::CHILD_AXIS));
NS_ENSURE_TRUE(nodeExpr, NS_ERROR_OUT_OF_MEMORY);
nt.forget();
txPushNewContext* pushContext = new txPushNewContext(Move(nodeExpr));
mContainerTemplate->mNext = pushContext;
NS_ENSURE_TRUE(pushContext, NS_ERROR_OUT_OF_MEMORY);
txApplyDefaultElementTemplate* applyTemplates =
new txApplyDefaultElementTemplate;
pushContext->mNext = applyTemplates;
NS_ENSURE_TRUE(applyTemplates, NS_ERROR_OUT_OF_MEMORY);
txLoopNodeSet* loopNodeSet = new txLoopNodeSet(applyTemplates);
applyTemplates->mNext = loopNodeSet;
NS_ENSURE_TRUE(loopNodeSet, NS_ERROR_OUT_OF_MEMORY);
txPopParams* popParams = new txPopParams;
pushContext->mBailTarget = loopNodeSet->mNext = popParams;
NS_ENSURE_TRUE(popParams, NS_ERROR_OUT_OF_MEMORY);
popParams->mNext = new txReturn();
NS_ENSURE_TRUE(popParams->mNext, NS_ERROR_OUT_OF_MEMORY);
// attribute/textnode template
nt = new txNodeTypeTest(txNodeTypeTest::NODE_TYPE);
NS_ENSURE_TRUE(nt, NS_ERROR_OUT_OF_MEMORY);
nodeExpr = new LocationStep(nt, LocationStep::SELF_AXIS);
NS_ENSURE_TRUE(nodeExpr, NS_ERROR_OUT_OF_MEMORY);
nt.forget();
mCharactersTemplate = new txValueOf(Move(nodeExpr), false);
NS_ENSURE_TRUE(mCharactersTemplate, NS_ERROR_OUT_OF_MEMORY);
mCharactersTemplate->mNext = new txReturn();
NS_ENSURE_TRUE(mCharactersTemplate->mNext, NS_ERROR_OUT_OF_MEMORY);
// pi/comment/namespace template
mEmptyTemplate = new txReturn();
NS_ENSURE_TRUE(mEmptyTemplate, NS_ERROR_OUT_OF_MEMORY);
return NS_OK;
}
@ -351,8 +332,6 @@ txStylesheet::doneCompiling()
if (!mDecimalFormats.get(txExpandedName())) {
nsAutoPtr<txDecimalFormat> format(new txDecimalFormat);
NS_ENSURE_TRUE(format, NS_ERROR_OUT_OF_MEMORY);
rv = mDecimalFormats.add(txExpandedName(), format);
NS_ENSURE_SUCCESS(rv, rv);
@ -394,8 +373,6 @@ txStylesheet::addTemplate(txTemplateItem* aTemplate,
if (!templates) {
nsAutoPtr< nsTArray<MatchableTemplate> > newList(
new nsTArray<MatchableTemplate>);
NS_ENSURE_TRUE(newList, NS_ERROR_OUT_OF_MEMORY);
rv = aImportFrame->mMatchableTemplates.set(aTemplate->mMode, newList);
NS_ENSURE_SUCCESS(rv, rv);
@ -546,8 +523,6 @@ txStylesheet::addGlobalVariable(txVariableItem* aVariable)
new GlobalVariable(Move(aVariable->mValue),
Move(aVariable->mFirstInstruction),
aVariable->mIsParam));
NS_ENSURE_TRUE(var, NS_ERROR_OUT_OF_MEMORY);
nsresult rv = mGlobalVariables.add(aVariable->mName, var);
NS_ENSURE_SUCCESS(rv, rv);
@ -566,8 +541,6 @@ txStylesheet::addKey(const txExpandedName& aName,
txXSLKey* xslKey = mKeys.get(aName);
if (!xslKey) {
xslKey = new txXSLKey(aName);
NS_ENSURE_TRUE(xslKey, NS_ERROR_OUT_OF_MEMORY);
rv = mKeys.add(aName, xslKey);
if (NS_FAILED(rv)) {
delete xslKey;

View File

@ -113,8 +113,6 @@ parseUseAttrSets(txStylesheetAttr* aAttributes,
NS_ENSURE_SUCCESS(rv, rv);
nsAutoPtr<txInstruction> instr(new txInsertAttrSet(name));
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
rv = aState.addInstruction(Move(instr));
NS_ENSURE_SUCCESS(rv, rv);
}
@ -191,7 +189,6 @@ getExprAttr(txStylesheetAttr* aAttributes,
attr->mValue
#endif
);
NS_ENSURE_TRUE(aExpr, NS_ERROR_OUT_OF_MEMORY);
}
else {
aExpr = nullptr;
@ -228,7 +225,6 @@ getAVTAttr(txStylesheetAttr* aAttributes,
attr->mValue
#endif
);
NS_ENSURE_TRUE(aAVT, NS_ERROR_OUT_OF_MEMORY);
}
else {
aAVT = nullptr;
@ -525,12 +521,8 @@ txFnStartLREStylesheet(int32_t aNamespaceID,
double prio = UnspecifiedNaN<double>();
nsAutoPtr<txPattern> match(new txRootPattern());
NS_ENSURE_TRUE(match, NS_ERROR_OUT_OF_MEMORY);
nsAutoPtr<txTemplateItem> templ(new txTemplateItem(Move(match), nullExpr,
nullExpr, prio));
NS_ENSURE_TRUE(templ, NS_ERROR_OUT_OF_MEMORY);
aState.openInstructionContainer(templ);
rv = aState.addToplevelItem(templ);
NS_ENSURE_SUCCESS(rv, rv);
@ -553,8 +545,6 @@ txFnEndLREStylesheet(txStylesheetCompilerState& aState)
aState.popHandlerTable();
nsAutoPtr<txInstruction> instr(new txReturn());
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
rv = aState.addInstruction(Move(instr));
NS_ENSURE_SUCCESS(rv, rv);
@ -638,8 +628,6 @@ txFnStartAttributeSet(int32_t aNamespaceID,
NS_ENSURE_SUCCESS(rv, rv);
nsAutoPtr<txAttributeSetItem> attrSet(new txAttributeSetItem(name));
NS_ENSURE_TRUE(attrSet, NS_ERROR_OUT_OF_MEMORY);
aState.openInstructionContainer(attrSet);
rv = aState.addToplevelItem(attrSet);
@ -659,8 +647,6 @@ txFnEndAttributeSet(txStylesheetCompilerState& aState)
aState.popHandlerTable();
nsAutoPtr<txInstruction> instr(new txReturn());
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
nsresult rv = aState.addInstruction(Move(instr));
NS_ENSURE_SUCCESS(rv, rv);
@ -686,8 +672,6 @@ txFnStartDecimalFormat(int32_t aNamespaceID,
NS_ENSURE_SUCCESS(rv, rv);
nsAutoPtr<txDecimalFormat> format(new txDecimalFormat);
NS_ENSURE_TRUE(format, NS_ERROR_OUT_OF_MEMORY);
rv = getCharAttr(aAttributes, aAttrCount, nsGkAtoms::decimalSeparator,
false, aState, format->mDecimalSeparator);
NS_ENSURE_SUCCESS(rv, rv);
@ -761,11 +745,7 @@ txFnStartImport(int32_t aNamespaceID,
txStylesheetCompilerState& aState)
{
nsAutoPtr<txImportItem> import(new txImportItem);
NS_ENSURE_TRUE(import, NS_ERROR_OUT_OF_MEMORY);
import->mFrame = new txStylesheet::ImportFrame;
NS_ENSURE_TRUE(import->mFrame, NS_ERROR_OUT_OF_MEMORY);
nsresult rv = aState.addToplevelItem(import);
NS_ENSURE_SUCCESS(rv, rv);
@ -910,7 +890,6 @@ txFnStartOutput(int32_t aNamespaceID,
nsresult rv = NS_OK;
nsAutoPtr<txOutputItem> item(new txOutputItem);
NS_ENSURE_TRUE(item, NS_ERROR_OUT_OF_MEMORY);
txExpandedName methodExpName;
rv = getQNameAttr(aAttributes, aAttrCount, nsGkAtoms::method, false,
@ -977,8 +956,6 @@ txFnStartOutput(int32_t aNamespaceID,
nsWhitespaceTokenizer tokens(attr->mValue);
while (tokens.hasMoreTokens()) {
nsAutoPtr<txExpandedName> qname(new txExpandedName());
NS_ENSURE_TRUE(qname, NS_ERROR_OUT_OF_MEMORY);
rv = qname->init(tokens.nextToken(),
aState.mElementContext->mMappings, false);
NS_ENSURE_SUCCESS(rv, rv);
@ -1033,8 +1010,6 @@ txFnStartStripSpace(int32_t aNamespaceID,
bool strip = aLocalName == nsGkAtoms::stripSpace;
nsAutoPtr<txStripSpaceItem> stripItem(new txStripSpaceItem);
NS_ENSURE_TRUE(stripItem, NS_ERROR_OUT_OF_MEMORY);
nsWhitespaceTokenizer tokenizer(attr->mValue);
while (tokenizer.hasMoreTokens()) {
const nsASingleFragmentString& name = tokenizer.nextToken();
@ -1075,8 +1050,6 @@ txFnStartStripSpace(int32_t aNamespaceID,
}
nsAutoPtr<txStripSpaceTest> sst(new txStripSpaceTest(prefix, localName,
ns, strip));
NS_ENSURE_TRUE(sst, NS_ERROR_OUT_OF_MEMORY);
rv = stripItem->addStripSpaceTest(sst);
NS_ENSURE_SUCCESS(rv, rv);
@ -1131,8 +1104,6 @@ txFnStartTemplate(int32_t aNamespaceID,
nsAutoPtr<txTemplateItem> templ(new txTemplateItem(Move(match), name, mode,
prio));
NS_ENSURE_TRUE(templ, NS_ERROR_OUT_OF_MEMORY);
aState.openInstructionContainer(templ);
rv = aState.addToplevelItem(templ);
NS_ENSURE_SUCCESS(rv, rv);
@ -1148,8 +1119,6 @@ txFnEndTemplate(txStylesheetCompilerState& aState)
aState.popHandlerTable();
nsAutoPtr<txInstruction> instr(new txReturn());
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
nsresult rv = aState.addInstruction(Move(instr));
NS_ENSURE_SUCCESS(rv, rv);
@ -1181,8 +1150,6 @@ txFnStartTopVariable(int32_t aNamespaceID,
nsAutoPtr<txVariableItem> var(
new txVariableItem(name, Move(select),
aLocalName == nsGkAtoms::param));
NS_ENSURE_TRUE(var, NS_ERROR_OUT_OF_MEMORY);
aState.openInstructionContainer(var);
rv = aState.pushPtr(var, aState.eVariableItem);
NS_ENSURE_SUCCESS(rv, rv);
@ -1218,13 +1185,10 @@ txFnEndTopVariable(txStylesheetCompilerState& aState)
NS_ASSERTION(!var->mValue,
"There shouldn't be a select-expression here");
var->mValue = new txLiteralExpr(EmptyString());
NS_ENSURE_TRUE(var->mValue, NS_ERROR_OUT_OF_MEMORY);
}
else if (!var->mValue) {
// If we don't have a select-expression there mush be children.
nsAutoPtr<txInstruction> instr(new txReturn());
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
nsresult rv = aState.addInstruction(Move(instr));
NS_ENSURE_SUCCESS(rv, rv);
}
@ -1282,8 +1246,6 @@ txFnStartLRE(int32_t aNamespaceID,
nsAutoPtr<txInstruction> instr(new txStartLREElement(aNamespaceID,
aLocalName, aPrefix));
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
rv = aState.addInstruction(Move(instr));
NS_ENSURE_SUCCESS(rv, rv);
@ -1313,8 +1275,6 @@ txFnStartLRE(int32_t aNamespaceID,
instr = new txLREAttribute(attr->mNamespaceID, attr->mLocalName,
attr->mPrefix, Move(avt));
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
rv = aState.addInstruction(Move(instr));
NS_ENSURE_SUCCESS(rv, rv);
}
@ -1326,8 +1286,6 @@ static nsresult
txFnEndLRE(txStylesheetCompilerState& aState)
{
nsAutoPtr<txInstruction> instr(new txEndElement);
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
nsresult rv = aState.addInstruction(Move(instr));
NS_ENSURE_SUCCESS(rv, rv);
@ -1345,8 +1303,6 @@ txFnText(const nsAString& aStr, txStylesheetCompilerState& aState)
TX_RETURN_IF_WHITESPACE(aStr, aState);
nsAutoPtr<txInstruction> instr(new txText(aStr, false));
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
nsresult rv = aState.addInstruction(Move(instr));
NS_ENSURE_SUCCESS(rv, rv);
@ -1370,14 +1326,10 @@ txFnStartApplyImports(int32_t aNamespaceID,
nsresult rv = NS_OK;
nsAutoPtr<txInstruction> instr(new txApplyImportsStart);
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
rv = aState.addInstruction(Move(instr));
NS_ENSURE_SUCCESS(rv, rv);
instr = new txApplyImportsEnd;
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
rv = aState.addInstruction(Move(instr));
NS_ENSURE_SUCCESS(rv, rv);
@ -1413,8 +1365,6 @@ txFnStartApplyTemplates(int32_t aNamespaceID,
nsresult rv = NS_OK;
nsAutoPtr<txInstruction> instr(new txPushParams);
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
rv = aState.addInstruction(Move(instr));
NS_ENSURE_SUCCESS(rv, rv);
@ -1424,8 +1374,6 @@ txFnStartApplyTemplates(int32_t aNamespaceID,
NS_ENSURE_SUCCESS(rv, rv);
instr = new txApplyTemplates(mode);
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
rv = aState.pushObject(instr);
NS_ENSURE_SUCCESS(rv, rv);
@ -1439,17 +1387,11 @@ txFnStartApplyTemplates(int32_t aNamespaceID,
if (!select) {
nsAutoPtr<txNodeTest> nt(
new txNodeTypeTest(txNodeTypeTest::NODE_TYPE));
NS_ENSURE_TRUE(nt, NS_ERROR_OUT_OF_MEMORY);
select = new LocationStep(nt, LocationStep::CHILD_AXIS);
NS_ENSURE_TRUE(select, NS_ERROR_OUT_OF_MEMORY);
nt.forget();
}
nsAutoPtr<txPushNewContext> pushcontext( new txPushNewContext(Move(select)));
NS_ENSURE_TRUE(pushcontext, NS_ERROR_OUT_OF_MEMORY);
rv = aState.pushSorter(pushcontext);
NS_ENSURE_SUCCESS(rv, rv);
@ -1476,8 +1418,6 @@ txFnEndApplyTemplates(txStylesheetCompilerState& aState)
instr = static_cast<txInstruction*>(aState.popObject()); // txApplyTemplates
nsAutoPtr<txLoopNodeSet> loop(new txLoopNodeSet(instr));
NS_ENSURE_TRUE(loop, NS_ERROR_OUT_OF_MEMORY);
rv = aState.addInstruction(Move(instr));
NS_ENSURE_SUCCESS(rv, rv);
@ -1486,8 +1426,6 @@ txFnEndApplyTemplates(txStylesheetCompilerState& aState)
NS_ENSURE_SUCCESS(rv, rv);
instr = new txPopParams;
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
pushcontext->mBailTarget = instr;
rv = aState.addInstruction(Move(instr));
NS_ENSURE_SUCCESS(rv, rv);
@ -1513,8 +1451,6 @@ txFnStartAttribute(int32_t aNamespaceID,
nsresult rv = NS_OK;
nsAutoPtr<txInstruction> instr(new txPushStringHandler(true));
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
rv = aState.addInstruction(Move(instr));
NS_ENSURE_SUCCESS(rv, rv);
@ -1530,8 +1466,6 @@ txFnStartAttribute(int32_t aNamespaceID,
instr = new txAttribute(Move(name), Move(nspace),
aState.mElementContext->mMappings);
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
rv = aState.pushObject(instr);
NS_ENSURE_SUCCESS(rv, rv);
@ -1573,8 +1507,6 @@ txFnStartCallTemplate(int32_t aNamespaceID,
nsresult rv = NS_OK;
nsAutoPtr<txInstruction> instr(new txPushParams);
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
rv = aState.addInstruction(Move(instr));
NS_ENSURE_SUCCESS(rv, rv);
@ -1584,8 +1516,6 @@ txFnStartCallTemplate(int32_t aNamespaceID,
NS_ENSURE_SUCCESS(rv, rv);
instr = new txCallTemplate(name);
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
rv = aState.pushObject(instr);
NS_ENSURE_SUCCESS(rv, rv);
@ -1605,8 +1535,6 @@ txFnEndCallTemplate(txStylesheetCompilerState& aState)
NS_ENSURE_SUCCESS(rv, rv);
instr = new txPopParams;
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
rv = aState.addInstruction(Move(instr));
NS_ENSURE_SUCCESS(rv, rv);
@ -1674,8 +1602,6 @@ txFnStartComment(int32_t aNamespaceID,
txStylesheetCompilerState& aState)
{
nsAutoPtr<txInstruction> instr(new txPushStringHandler(true));
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
nsresult rv = aState.addInstruction(Move(instr));
NS_ENSURE_SUCCESS(rv, rv);
@ -1686,8 +1612,6 @@ static nsresult
txFnEndComment(txStylesheetCompilerState& aState)
{
nsAutoPtr<txInstruction> instr(new txComment);
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
nsresult rv = aState.addInstruction(Move(instr));
NS_ENSURE_SUCCESS(rv, rv);
@ -1712,8 +1636,6 @@ txFnStartCopy(int32_t aNamespaceID,
txStylesheetCompilerState& aState)
{
nsAutoPtr<txCopy> copy(new txCopy);
NS_ENSURE_TRUE(copy, NS_ERROR_OUT_OF_MEMORY);
nsresult rv = aState.pushPtr(copy, aState.eCopy);
NS_ENSURE_SUCCESS(rv, rv);
@ -1731,8 +1653,6 @@ static nsresult
txFnEndCopy(txStylesheetCompilerState& aState)
{
nsAutoPtr<txInstruction> instr(new txEndElement);
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
nsresult rv = aState.addInstruction(Move(instr));
NS_ENSURE_SUCCESS(rv, rv);
@ -1764,8 +1684,6 @@ txFnStartCopyOf(int32_t aNamespaceID,
NS_ENSURE_SUCCESS(rv, rv);
nsAutoPtr<txInstruction> instr(new txCopyOf(Move(select)));
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
rv = aState.addInstruction(Move(instr));
NS_ENSURE_SUCCESS(rv, rv);
@ -1810,8 +1728,6 @@ txFnStartElement(int32_t aNamespaceID,
nsAutoPtr<txInstruction> instr(
new txStartElement(Move(name), Move(nspace),
aState.mElementContext->mMappings));
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
rv = aState.addInstruction(Move(instr));
NS_ENSURE_SUCCESS(rv, rv);
@ -1825,8 +1741,6 @@ static nsresult
txFnEndElement(txStylesheetCompilerState& aState)
{
nsAutoPtr<txInstruction> instr(new txEndElement);
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
nsresult rv = aState.addInstruction(Move(instr));
NS_ENSURE_SUCCESS(rv, rv);
@ -1886,8 +1800,6 @@ txFnStartForEach(int32_t aNamespaceID,
NS_ENSURE_SUCCESS(rv, rv);
nsAutoPtr<txPushNewContext> pushcontext(new txPushNewContext(Move(select)));
NS_ENSURE_TRUE(pushcontext, NS_ERROR_OUT_OF_MEMORY);
rv = aState.pushPtr(pushcontext, aState.ePushNewContext);
NS_ENSURE_SUCCESS(rv, rv);
@ -1899,8 +1811,6 @@ txFnStartForEach(int32_t aNamespaceID,
NS_ENSURE_SUCCESS(rv, rv);
instr = new txPushNullTemplateRule;
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
rv = aState.pushPtr(instr, aState.ePushNullTemplateRule);
NS_ENSURE_SUCCESS(rv, rv);
@ -1979,8 +1889,6 @@ txFnStartIf(int32_t aNamespaceID,
nsAutoPtr<txConditionalGoto> condGoto(new txConditionalGoto(Move(test),
nullptr));
NS_ENSURE_TRUE(condGoto, NS_ERROR_OUT_OF_MEMORY);
rv = aState.pushPtr(condGoto, aState.eConditionalGoto);
NS_ENSURE_SUCCESS(rv, rv);
@ -2015,8 +1923,6 @@ txFnStartMessage(int32_t aNamespaceID,
txStylesheetCompilerState& aState)
{
nsAutoPtr<txInstruction> instr(new txPushStringHandler(false));
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
nsresult rv = aState.addInstruction(Move(instr));
NS_ENSURE_SUCCESS(rv, rv);
@ -2026,8 +1932,6 @@ txFnStartMessage(int32_t aNamespaceID,
NS_ENSURE_SUCCESS(rv, rv);
instr = new txMessage(term == eTrue);
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
rv = aState.pushObject(instr);
NS_ENSURE_SUCCESS(rv, rv);
@ -2121,8 +2025,6 @@ txFnStartNumber(int32_t aNamespaceID,
Move(value), Move(format),
Move(groupingSeparator),
Move(groupingSize)));
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
rv = aState.addInstruction(Move(instr));
NS_ENSURE_SUCCESS(rv, rv);
@ -2202,8 +2104,6 @@ txFnStartParam(int32_t aNamespaceID,
NS_ENSURE_SUCCESS(rv, rv);
nsAutoPtr<txSetVariable> var(new txSetVariable(name, Move(select)));
NS_ENSURE_TRUE(var, NS_ERROR_OUT_OF_MEMORY);
if (var->mValue) {
// XXX should be gTxErrorHandler?
rv = aState.pushHandlerTable(gTxIgnoreHandler);
@ -2235,7 +2135,6 @@ txFnEndParam(txStylesheetCompilerState& aState)
NS_ASSERTION(!var->mValue,
"There shouldn't be a select-expression here");
var->mValue = new txLiteralExpr(EmptyString());
NS_ENSURE_TRUE(var->mValue, NS_ERROR_OUT_OF_MEMORY);
}
nsresult rv = aState.addVariable(var->mName);
@ -2268,8 +2167,6 @@ txFnStartPI(int32_t aNamespaceID,
txStylesheetCompilerState& aState)
{
nsAutoPtr<txInstruction> instr(new txPushStringHandler(true));
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
nsresult rv = aState.addInstruction(Move(instr));
NS_ENSURE_SUCCESS(rv, rv);
@ -2279,8 +2176,6 @@ txFnStartPI(int32_t aNamespaceID,
NS_ENSURE_SUCCESS(rv, rv);
instr = new txProcessingInstruction(Move(name));
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
rv = aState.pushObject(instr);
NS_ENSURE_SUCCESS(rv, rv);
@ -2323,10 +2218,8 @@ txFnStartSort(int32_t aNamespaceID,
if (!select) {
nsAutoPtr<txNodeTest> nt(
new txNodeTypeTest(txNodeTypeTest::NODE_TYPE));
NS_ENSURE_TRUE(nt, NS_ERROR_OUT_OF_MEMORY);
select = new LocationStep(nt, LocationStep::SELF_AXIS);
NS_ENSURE_TRUE(select, NS_ERROR_OUT_OF_MEMORY);
nt.forget();
}
@ -2405,8 +2298,6 @@ static nsresult
txFnTextText(const nsAString& aStr, txStylesheetCompilerState& aState)
{
nsAutoPtr<txInstruction> instr(new txText(aStr, aState.mDOE));
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
nsresult rv = aState.addInstruction(Move(instr));
NS_ENSURE_SUCCESS(rv, rv);
@ -2440,8 +2331,6 @@ txFnStartValueOf(int32_t aNamespaceID,
NS_ENSURE_SUCCESS(rv, rv);
nsAutoPtr<txInstruction> instr(new txValueOf(Move(select), doe == eTrue));
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
rv = aState.addInstruction(Move(instr));
NS_ENSURE_SUCCESS(rv, rv);
@ -2483,8 +2372,6 @@ txFnStartVariable(int32_t aNamespaceID,
NS_ENSURE_SUCCESS(rv, rv);
nsAutoPtr<txSetVariable> var(new txSetVariable(name, Move(select)));
NS_ENSURE_TRUE(var, NS_ERROR_OUT_OF_MEMORY);
if (var->mValue) {
// XXX should be gTxErrorHandler?
rv = aState.pushHandlerTable(gTxIgnoreHandler);
@ -2517,7 +2404,6 @@ txFnEndVariable(txStylesheetCompilerState& aState)
NS_ASSERTION(!var->mValue,
"There shouldn't be a select-expression here");
var->mValue = new txLiteralExpr(EmptyString());
NS_ENSURE_TRUE(var->mValue, NS_ERROR_OUT_OF_MEMORY);
}
nsresult rv = aState.addVariable(var->mName);
@ -2539,8 +2425,6 @@ txFnStartElementStartRTF(int32_t aNamespaceID,
txStylesheetCompilerState& aState)
{
nsAutoPtr<txInstruction> instr(new txPushRTFHandler);
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
nsresult rv = aState.addInstruction(Move(instr));
NS_ENSURE_SUCCESS(rv, rv);
@ -2555,8 +2439,6 @@ txFnTextStartRTF(const nsAString& aStr, txStylesheetCompilerState& aState)
TX_RETURN_IF_WHITESPACE(aStr, aState);
nsAutoPtr<txInstruction> instr(new txPushRTFHandler);
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
nsresult rv = aState.addInstruction(Move(instr));
NS_ENSURE_SUCCESS(rv, rv);
@ -2587,8 +2469,6 @@ txFnStartWhen(int32_t aNamespaceID,
nsAutoPtr<txConditionalGoto> condGoto(new txConditionalGoto(Move(test),
nullptr));
NS_ENSURE_TRUE(condGoto, NS_ERROR_OUT_OF_MEMORY);
rv = aState.pushPtr(condGoto, aState.eConditionalGoto);
NS_ENSURE_SUCCESS(rv, rv);
@ -2604,8 +2484,6 @@ txFnEndWhen(txStylesheetCompilerState& aState)
{
aState.popHandlerTable();
nsAutoPtr<txGoTo> gotoinstr(new txGoTo(nullptr));
NS_ENSURE_TRUE(gotoinstr, NS_ERROR_OUT_OF_MEMORY);
nsresult rv = aState.mChooseGotoList->add(gotoinstr);
NS_ENSURE_SUCCESS(rv, rv);
@ -2649,8 +2527,6 @@ txFnStartWithParam(int32_t aNamespaceID,
NS_ENSURE_SUCCESS(rv, rv);
nsAutoPtr<txSetParam> var(new txSetParam(name, Move(select)));
NS_ENSURE_TRUE(var, NS_ERROR_OUT_OF_MEMORY);
if (var->mValue) {
// XXX should be gTxErrorHandler?
rv = aState.pushHandlerTable(gTxIgnoreHandler);
@ -2681,7 +2557,6 @@ txFnEndWithParam(txStylesheetCompilerState& aState)
NS_ASSERTION(!var->mValue,
"There shouldn't be a select-expression here");
var->mValue = new txLiteralExpr(EmptyString());
NS_ENSURE_TRUE(var->mValue, NS_ERROR_OUT_OF_MEMORY);
}
nsAutoPtr<txInstruction> instr(var.forget());
@ -2725,8 +2600,6 @@ txFnEndUnknownInstruction(txStylesheetCompilerState& aState)
if (aState.mSearchingForFallback) {
nsAutoPtr<txInstruction> instr(new txErrorInstruction());
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
nsresult rv = aState.addInstruction(Move(instr));
NS_ENSURE_SUCCESS(rv, rv);
}

View File

@ -85,8 +85,6 @@ txStylesheetCompiler::startElement(int32_t aNamespaceID, nsIAtom* aLocalName,
if (!hasOwnNamespaceMap) {
mElementContext->mMappings =
new txNamespaceMap(*mElementContext->mMappings);
NS_ENSURE_TRUE(mElementContext->mMappings,
NS_ERROR_OUT_OF_MEMORY);
hasOwnNamespaceMap = true;
}
@ -121,7 +119,6 @@ txStylesheetCompiler::startElement(const char16_t *aName,
nsAutoArrayPtr<txStylesheetAttr> atts;
if (aAttrCount > 0) {
atts = new txStylesheetAttr[aAttrCount];
NS_ENSURE_TRUE(atts, NS_ERROR_OUT_OF_MEMORY);
}
bool hasOwnNamespaceMap = false;
@ -149,8 +146,6 @@ txStylesheetCompiler::startElement(const char16_t *aName,
if (!hasOwnNamespaceMap) {
mElementContext->mMappings =
new txNamespaceMap(*mElementContext->mMappings);
NS_ENSURE_TRUE(mElementContext->mMappings,
NS_ERROR_OUT_OF_MEMORY);
hasOwnNamespaceMap = true;
}
@ -336,8 +331,6 @@ txStylesheetCompiler::endElement()
txInScopeVariable* var = mInScopeVariables[i];
if (!--(var->mLevel)) {
nsAutoPtr<txInstruction> instr(new txRemoveVariable(var->mName));
NS_ENSURE_TRUE(instr, NS_ERROR_OUT_OF_MEMORY);
rv = addInstruction(Move(instr));
NS_ENSURE_SUCCESS(rv, rv);
@ -482,8 +475,6 @@ txStylesheetCompiler::ensureNewElementContext()
nsAutoPtr<txElementContext>
context(new txElementContext(*mElementContext));
NS_ENSURE_TRUE(context, NS_ERROR_OUT_OF_MEMORY);
nsresult rv = pushObject(mElementContext);
NS_ENSURE_SUCCESS(rv, rv);
@ -572,8 +563,6 @@ txStylesheetCompilerState::init(const nsAString& aStylesheetURI,
}
else {
mStylesheet = new txStylesheet;
NS_ENSURE_TRUE(mStylesheet, NS_ERROR_OUT_OF_MEMORY);
rv = mStylesheet->init();
NS_ENSURE_SUCCESS(rv, rv);
@ -584,8 +573,7 @@ txStylesheetCompilerState::init(const nsAString& aStylesheetURI,
}
mElementContext = new txElementContext(aStylesheetURI);
NS_ENSURE_TRUE(mElementContext && mElementContext->mMappings,
NS_ERROR_OUT_OF_MEMORY);
NS_ENSURE_TRUE(mElementContext->mMappings, NS_ERROR_OUT_OF_MEMORY);
// Push the "old" txElementContext
rv = pushObject(0);
@ -649,7 +637,6 @@ txStylesheetCompilerState::pushChooseGotoList()
mChooseGotoList.forget();
mChooseGotoList = new txList;
NS_ENSURE_TRUE(mChooseGotoList, NS_ERROR_OUT_OF_MEMORY);
return NS_OK;
}
@ -841,8 +828,6 @@ nsresult
txStylesheetCompilerState::addVariable(const txExpandedName& aName)
{
txInScopeVariable* var = new txInScopeVariable(aName);
NS_ENSURE_TRUE(var, NS_ERROR_OUT_OF_MEMORY);
if (!mInScopeVariables.AppendElement(var)) {
delete var;
return NS_ERROR_OUT_OF_MEMORY;
@ -963,7 +948,8 @@ TX_ConstructXSLTFunction(nsIAtom* aName, int32_t aNamespaceID,
return NS_ERROR_XPATH_UNKNOWN_FUNCTION;
}
return *aFunction ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
MOZ_ASSERT(*aFunction);
return NS_OK;
}
typedef nsresult (*txFunctionFactory)(nsIAtom* aName,
@ -1034,9 +1020,6 @@ findFunction(nsIAtom* aName, int32_t aNamespaceID,
if (!sXPCOMFunctionMappings) {
sXPCOMFunctionMappings = new nsTArray<txXPCOMFunctionMapping>;
if (!sXPCOMFunctionMappings) {
return NS_ERROR_OUT_OF_MEMORY;
}
}
txXPCOMFunctionMapping *map = nullptr;
@ -1104,7 +1087,7 @@ txStylesheetCompilerState::resolveFunctionCall(nsIAtom* aName, int32_t aID,
if (rv == NS_ERROR_XPATH_UNKNOWN_FUNCTION &&
(aID != kNameSpaceID_None || fcp())) {
*aFunction = new txErrorFunctionCall(aName);
rv = *aFunction ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
rv = NS_OK;
}
return rv;

View File

@ -73,10 +73,6 @@ txResultStringComparator::createSortableValue(Expr *aExpr,
return NS_ERROR_FAILURE;
val->mCaseKey = new nsString;
if (!val->mCaseKey) {
return NS_ERROR_OUT_OF_MEMORY;
}
nsString& nsCaseKey = *(nsString *)val->mCaseKey;
nsresult rv = aExpr->evaluateToString(aContext, nsCaseKey);
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -137,11 +137,9 @@ txXSLTNumber::getValueList(Expr* aValueExpr, txPattern* aCountPattern,
{
txNodeTypeTest* typeTest;
typeTest = new txNodeTypeTest(txNodeTypeTest::PI_TYPE);
if (typeTest) {
nsAutoString nodeName;
txXPathNodeUtils::getNodeName(currNode, nodeName);
typeTest->setNodeName(nodeName);
}
nsAutoString nodeName;
txXPathNodeUtils::getNodeName(currNode, nodeName);
typeTest->setNodeName(nodeName);
nodeTest = typeTest;
break;
}
@ -161,14 +159,8 @@ txXSLTNumber::getValueList(Expr* aValueExpr, txPattern* aCountPattern,
break;
}
}
NS_ENSURE_TRUE(nodeTest, NS_ERROR_OUT_OF_MEMORY);
MOZ_ASSERT(nodeTest);
countPattern = new txStepPattern(nodeTest, false);
if (!countPattern) {
// XXX error reporting
delete nodeTest;
return NS_ERROR_OUT_OF_MEMORY;
}
}

View File

@ -80,7 +80,8 @@ txFormattedCounter::getCounterFor(const nsAFlatString& aToken,
aGroupSeparator);
break;
}
return aCounter ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
MOZ_ASSERT(aCounter);
return NS_OK;
}
// for now, the only multi-char token we support are decimals
@ -96,8 +97,8 @@ txFormattedCounter::getCounterFor(const nsAFlatString& aToken,
// if we don't recognize the token then use '1'
aCounter = new txDecimalCounter(1, aGroupSize, aGroupSeparator);
}
return aCounter ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
MOZ_ASSERT(aCounter);
return NS_OK;
}