if (0 == mTextSize) { mText = (PRUnichar *) PR_MALLOC(sizeof(PRUnichar) * 4096); if (nsnull == mText) { return NS_ERROR_OUT_OF_MEMORY; } mTextSize = 4096; }   PRInt32 offset = 0; while (0 != aLength) { PRInt32 amount = mTextSize - mTextLength; if (amount > aLength) { amount = aLength; } if (0 == amount) { if (mConstrainSize) { nsresult rv = FlushText(); if (NS_OK != rv) { return rv; } } else { mTextSize += aLength; mText = (PRUnichar *) PR_REALLOC(mText, sizeof(PRUnichar) * mTextSize); if (nsnull == mText) {
if (0 == mTextSize) { mText = (PRUnichar *) PR_MALLOC(sizeof(PRUnichar) * 4096); if (!mText) {
RDFContentSinkImpl::AddText(const PRUnichar* aText, PRInt32 aLength){  // Create buffer when we first need it  if (0 == mTextSize) {      mText = (PRUnichar *) PR_MALLOC(sizeof(PRUnichar) * 4096);      if (nsnull == mText) {          return NS_ERROR_OUT_OF_MEMORY;      }      mTextSize = 4096;  }  // Copy data from string into our buffer; flush buffer when it fills up  PRInt32 offset = 0;  while (0 != aLength) {    PRInt32 amount = mTextSize - mTextLength;    if (amount > aLength) {        amount = aLength;    }    if (0 == amount) {      if (mConstrainSize) {        nsresult rv = FlushText();        if (NS_OK != rv) {            return rv;        }      }      else {        mTextSize += aLength;        mText = (PRUnichar *) PR_REALLOC(mText, sizeof(PRUnichar) * mTextSize);        if (nsnull == mText) {            return NS_ERROR_OUT_OF_MEMORY;        }      }    }    memcpy(&mText[mTextLength],aText + offset, sizeof(PRUnichar) * amount);        mTextLength += amount;    offset += amount;    aLength -= amount;  }  return NS_OK;}