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);
XChar2b buf[512]; char *p; PRInt32 bufLen; int textWidth;
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;}