prev = nsnull;
InMemoryDataSource::LockedAssert(nsIRDFResource* aSource,                                 nsIRDFResource* aProperty,                                 nsIRDFNode* aTarget,                                 PRBool aTruthValue){#ifdef PR_LOGGING    LogOperation("ASSERT", aSource, aProperty, aTarget, aTruthValue);#endif    Assertion* next = GetForwardArcs(aSource);    Assertion* prev = next;    Assertion* as = nsnull;    // Walk to the end of the linked list.    // XXX shouldn't we just keep a pointer to the end, or insert at the front???    while (next) {        if (aProperty == next->mProperty) {            if (aTarget == next->mTarget) {                // Wow, we already had the assertion. Make sure that the                // truth values are correct and bail.                next->mTruthValue = aTruthValue;                return NS_OK;            }        }        prev = next;        next = next->mNext;    }    as = Assertion::Create(mAllocator, aSource, aProperty, aTarget, aTruthValue);    if (! as)        return NS_ERROR_OUT_OF_MEMORY;    // Link it in to the "forward arcs" table    if (!prev) {        SetForwardArcs(aSource, as);    } else {        prev->mNext = as;    }    // Link it in to the "reverse arcs" table    // XXX Shouldn't we keep a pointer to the end of the list to make    // sure this is O(1)?    prev = nsnull;    next = GetReverseArcs(aTarget);    while (next) {        prev = next;        next = next->mInvNext;    }    if (!prev) {        SetReverseArcs(aTarget, as);    } else {        prev->mInvNext = as;    }    // Add the datasource's owning reference.    as->AddRef();    return NS_OK;}