readBuf = (char *)PR_Malloc(fileSize); if (!readBuf) return NS_ERROR_OUT_OF_MEMORY;
PrefParseState ps; PREF_InitParseState(&ps, PREF_ReaderCallback, NULL); for (;;) { PRUint32 amtRead = 0; rv = inStr->Read(readBuf, sizeof(readBuf), &amtRead); if (NS_FAILED(rv) || amtRead == 0) break;
static nsresult openPrefFile(nsIFile* aFile, PRBool aIsErrorFatal,                             PRBool aIsGlobalContext, PRBool aSkipFirstLine){  nsCOMPtr<nsIInputStream> inStr;  char *readBuf;  PRInt64 llFileSize;  PRUint32 fileSize;  nsresult rv;#if MOZ_TIMELINE  {    nsCAutoString str;    aFile->GetNativePath(str);    NS_TIMELINE_MARK_FUNCTION1("load pref file", str.get());  }#endif  rv = aFile->GetFileSize(&llFileSize);  if (NS_FAILED(rv))    return rv;          LL_L2UI(fileSize, llFileSize); // Converting 64 bit structure to unsigned int  // Now that we know the file exists, set this flag until we have  // successfully read and evaluated the prefs file. This will  // prevent us from writing an empty or partial prefs.js.    gErrorOpeningUserPrefs = aIsErrorFatal;  rv = NS_NewLocalFileInputStream(getter_AddRefs(inStr), aFile);  if (NS_FAILED(rv))     return rv;          // XXX maybe we should read the file in chunks instead??  readBuf = (char *)PR_Malloc(fileSize);  if (!readBuf)     return NS_ERROR_OUT_OF_MEMORY;  PRUint32 amtRead = 0;  rv = inStr->Read(readBuf, fileSize, &amtRead);  NS_ASSERTION((amtRead == fileSize), "failed to read the entire prefs file!!");  if (amtRead != fileSize)    return NS_ERROR_FAILURE; #ifdef XP_OS2 /* OS/2 workaround - our system editor adds an EOF character */     if (readBuf[amtRead - 1] == 0x1A) {        amtRead--;     } #endif  if (NS_SUCCEEDED(rv)) {    nsCAutoString leafName;    aFile->GetNativeLeafName(leafName);    if (PREF_EvaluateConfigScript(readBuf, amtRead, leafName.get(), aIsGlobalContext, PR_TRUE,                                   aSkipFirstLine))      gErrorOpeningUserPrefs = PR_FALSE;    else      rv = NS_ERROR_FAILURE;  }  PR_Free(readBuf);  return rv;        }