Bug 1233234 - part 3 - clean up UniquePtr usage in WritePrefFile; r=njn

We shouldn't use .get() on UniquePtr<T[]> unless we have to, and it
makes the code clearer to not use pointer incrementing in any event.
This commit is contained in:
Nathan Froyd 2015-12-06 09:11:55 -05:00
parent 23a987ee55
commit 0e8de7a4cc

View File

@ -948,12 +948,13 @@ Preferences::WritePrefFile(nsIFile* aFile)
// write out the file header
outStream->Write(outHeader, sizeof(outHeader) - 1, &writeAmount);
char** walker = valueArray.get();
for (uint32_t valueIdx = 0; valueIdx < gHashTable->EntryCount(); valueIdx++, walker++) {
if (*walker) {
outStream->Write(*walker, strlen(*walker), &writeAmount);
for (uint32_t valueIdx = 0; valueIdx < gHashTable->EntryCount(); valueIdx++) {
char*& pref = valueArray[valueIdx];
if (pref) {
outStream->Write(pref, strlen(pref), &writeAmount);
outStream->Write(NS_LINEBREAK, NS_LINEBREAK_LEN, &writeAmount);
free(*walker);
free(pref);
pref = nullptr;
}
}