}
static nsresult EnumFonts(const char * aLangGroup, const char* aGeneric, PRUint32* aCount, PRUnichar*** aResult) {   nsString font_name;       int32 numFamilies = count_font_families();    PRUnichar** array =     (PRUnichar**) nsMemory::Alloc(numFamilies * sizeof(PRUnichar*));   if (!array)     return NS_ERROR_OUT_OF_MEMORY;   int j = 0;  for(int32 i = 0; i < numFamilies; i++)   {    font_family family;     uint32 flags;     if (get_font_family(i, &family, &flags) == B_OK)     {      if (family && (!aLangGroup || MatchesLangGroup(family,  aLangGroup)))      {        if(FontMatchesGenericType(family, flags, aGeneric, aLangGroup))        {          font_name.AssignWithConversion(family);           if (!(array[j] = ToNewUnicode(font_name)))            break;           ++j;        }      }    }  }    NS_QuickSort(array, j, sizeof(PRUnichar*), CompareFontNames, nsnull);    *aCount = j;   if (*aCount)    *aResult = array;   else     nsMemory::Free(array);   return NS_OK; } 