Skip to content

Commit

Permalink
Bug 856455 - Make nsCOMArray::SetCapacity return void; r=bsmedberg
Browse files Browse the repository at this point in the history
--HG--
extra : rebase_source : 38cdef904f9b7fc33bd3f41bd19b1778dfbd7990
  • Loading branch information
ehsan committed Mar 31, 2013
1 parent c9d752c commit b0d7171
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 21 deletions.
5 changes: 1 addition & 4 deletions content/base/src/nsDOMMutationObserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,7 @@ nsDOMMutationObserver::Observe(nsINode& aTarget,
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
return;
}
if (!filters.SetCapacity(len)) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return;
}
filters.SetCapacity(len);

for (uint32_t i = 0; i < len; ++i) {
nsCOMPtr<nsIAtom> a = do_GetAtom(filtersAsString[i]);
Expand Down
3 changes: 1 addition & 2 deletions dom/base/nsMimeTypeArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,7 @@ nsMimeTypeArray::GetMimeTypes()
}
}
// now we know how many there are, start gathering them.
if (!mMimeTypeArray.SetCapacity(pluginMimeTypeCount))
return NS_ERROR_OUT_OF_MEMORY;
mMimeTypeArray.SetCapacity(pluginMimeTypeCount);

mPluginMimeTypeCount = pluginMimeTypeCount;
mInited = true;
Expand Down
4 changes: 1 addition & 3 deletions netwerk/base/src/nsLoadGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -707,9 +707,7 @@ NS_IMETHODIMP
nsLoadGroup::GetRequests(nsISimpleEnumerator * *aRequests)
{
nsCOMArray<nsIRequest> requests;
if (!requests.SetCapacity(mRequests.entryCount)) {
return NS_ERROR_OUT_OF_MEMORY;
}
requests.SetCapacity(mRequests.entryCount);

PL_DHashTableEnumerate(&mRequests, AppendRequestsToCOMArray, &requests);

Expand Down
4 changes: 1 addition & 3 deletions rdf/base/src/nsInMemoryDataSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1658,9 +1658,7 @@ NS_IMETHODIMP
InMemoryDataSource::GetAllResources(nsISimpleEnumerator** aResult)
{
nsCOMArray<nsIRDFNode> nodes;
if (!nodes.SetCapacity(mForwardArcs.entryCount)) {
return NS_ERROR_OUT_OF_MEMORY;
}
nodes.SetCapacity(mForwardArcs.entryCount);

// Enumerate all of our entries into an nsCOMArray
PL_DHashTableEnumerate(&mForwardArcs, ResourceEnumerator, &nodes);
Expand Down
6 changes: 2 additions & 4 deletions rdf/datasource/src/nsFileSystemDataSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -733,12 +733,10 @@ FileSystemDataSource::ArcLabelsOut(nsIRDFResource *source,
if (! labels)
return NS_ERROR_NULL_POINTER;

nsresult rv;

if (source == mNC_FileSystemRoot)
{
nsCOMArray<nsIRDFResource> resources;
if (!resources.SetCapacity(2)) return NS_ERROR_OUT_OF_MEMORY;
resources.SetCapacity(2);

resources.AppendObject(mNC_Child);
resources.AppendObject(mNC_pulse);
Expand All @@ -748,7 +746,7 @@ FileSystemDataSource::ArcLabelsOut(nsIRDFResource *source,
else if (isFileURI(source))
{
nsCOMArray<nsIRDFResource> resources;
if (!resources.SetCapacity(2)) return NS_ERROR_OUT_OF_MEMORY;
resources.SetCapacity(2);

if (isDirURI(source))
{
Expand Down
3 changes: 1 addition & 2 deletions xpcom/ds/nsPersistentProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,8 +611,7 @@ nsPersistentProperties::Enumerate(nsISimpleEnumerator** aResult)
nsCOMArray<nsIPropertyElement> props;

// We know the necessary size; we can avoid growing it while adding elements
if (!props.SetCapacity(mTable.entryCount))
return NS_ERROR_OUT_OF_MEMORY;
props.SetCapacity(mTable.entryCount);

// Step through hash entries populating a transient array
uint32_t n =
Expand Down
4 changes: 1 addition & 3 deletions xpcom/glue/nsCOMArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,8 @@ class NS_COM_GLUE nsCOMArray_base

// Ensures there is enough space to store a total of aCapacity objects.
// This method never deletes any objects.
bool SetCapacity(uint32_t aCapacity) {
void SetCapacity(uint32_t aCapacity) {
mArray.SetCapacity(aCapacity);
// TODO: Make this method return void
return true;
}
uint32_t Capacity() {
return mArray.Capacity();
Expand Down

0 comments on commit b0d7171

Please sign in to comment.