Bug 1378680 - Refactor usage fallible alloc in url-classifier r=francois

MozReview-Commit-ID: HHG1ByeIwZv
This commit is contained in:
Thomas Nguyen
2017-07-20 16:20:27 +08:00
parent 46fb70612a
commit 41442f215a
9 changed files with 105 additions and 46 deletions

View File

@@ -616,7 +616,10 @@ LookupCacheV2::Build(AddPrefixArray& aAddPrefixes,
static_cast<uint32_t>(aAddCompletes.Length()));
mUpdateCompletions.Clear();
mUpdateCompletions.SetCapacity(aAddCompletes.Length());
if (!mUpdateCompletions.SetCapacity(aAddCompletes.Length(), fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
for (uint32_t i = 0; i < aAddCompletes.Length(); i++) {
mUpdateCompletions.AppendElement(aAddCompletes[i].CompleteHash());
}
@@ -683,8 +686,12 @@ LookupCacheV2::ReadCompletions()
NS_ENSURE_SUCCESS(rv, rv);
mUpdateCompletions.Clear();
const AddCompleteArray& addComplete = store.AddCompletes();
if (!mUpdateCompletions.SetCapacity(addComplete.Length(), fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
for (uint32_t i = 0; i < addComplete.Length(); i++) {
mUpdateCompletions.AppendElement(addComplete[i].complete);
}