ENCODER_BUFFER_ALLOC_IF_NEEDED(p, mCharSetInfo->mConverter, aString, aLength, buf, sizeof(buf), bufLen);  int len = mCharSetInfo->Convert(mCharSetInfo, (XFontStruct*) mFont, aString, aLength, p, bufLen);  if ((mFont->min_byte1 == 0) && (mFont->max_byte1 == 0)) textWidth = XTextWidth(mFont, p, len); else textWidth = XTextWidth16(mFont, (XChar2b *)p, len / 2);  ENCODER_BUFFER_FREE_IF_NEEDED(p, buf);
nsFontXlibSubstitute::GetWidth(const PRUnichar* aString, PRUint32 aLength){  PRUnichar buf[512];  PRUnichar *p = buf;  PRUint32 bufLen = sizeof(buf) / sizeof(PRUnichar);  if ((aLength * 2) > bufLen) {    PRUnichar *tmp;    tmp = (PRUnichar*)nsMemory::Alloc(sizeof(PRUnichar) * (aLength * 2));    if (tmp) {      p = tmp;      bufLen = (aLength * 2);    }  }  PRUint32 len = Convert(aString, aLength, p, bufLen);  int textWidth = mSubstituteFont->GetWidth(p, len);  if (p != buf)    nsMemory::Free(p);  return textWidth;}