1998-05-23 01:56:30 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/*
|
1999-11-06 06:43:54 +03:00
|
|
|
* The contents of this file are subject to the Netscape Public
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/NPL/
|
1998-05-23 01:56:30 +04:00
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
1998-05-23 01:56:30 +04:00
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1998-05-23 01:56:30 +04:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 06:43:54 +03:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1999-12-01 02:36:32 +03:00
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
1998-05-23 01:56:30 +04:00
|
|
|
*/
|
|
|
|
|
1999-02-23 11:10:24 +03:00
|
|
|
#include "nsSupportsArray.h"
|
|
|
|
#include "nsSupportsArrayEnumerator.h"
|
1999-09-06 23:04:09 +04:00
|
|
|
#include <string.h>
|
1998-05-23 01:56:30 +04:00
|
|
|
|
1999-02-23 11:10:24 +03:00
|
|
|
static const PRUint32 kGrowArrayBy = 8;
|
1998-05-23 01:56:30 +04:00
|
|
|
|
1999-02-23 11:10:24 +03:00
|
|
|
nsSupportsArray::nsSupportsArray()
|
1998-05-23 01:56:30 +04:00
|
|
|
{
|
|
|
|
NS_INIT_REFCNT();
|
|
|
|
mArray = &(mAutoArray[0]);
|
|
|
|
mArraySize = kAutoArraySize;
|
|
|
|
mCount = 0;
|
|
|
|
}
|
|
|
|
|
1999-02-23 11:10:24 +03:00
|
|
|
nsSupportsArray::~nsSupportsArray()
|
1998-05-23 01:56:30 +04:00
|
|
|
{
|
|
|
|
DeleteArray();
|
|
|
|
}
|
|
|
|
|
1999-05-26 05:38:36 +04:00
|
|
|
NS_METHOD
|
|
|
|
nsSupportsArray::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
|
|
|
{
|
|
|
|
if (aOuter)
|
|
|
|
return NS_ERROR_NO_AGGREGATION;
|
|
|
|
|
|
|
|
nsSupportsArray *it = new nsSupportsArray();
|
|
|
|
if (it == NULL)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
NS_ADDREF(it);
|
|
|
|
nsresult rv = it->QueryInterface(aIID, aResult);
|
|
|
|
NS_RELEASE(it);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2000-03-06 00:26:01 +03:00
|
|
|
NS_IMPL_THREADSAFE_ISUPPORTS1(nsSupportsArray, nsISupportsArray)
|
1998-05-23 01:56:30 +04:00
|
|
|
|
1999-02-23 11:10:24 +03:00
|
|
|
void nsSupportsArray::DeleteArray(void)
|
1998-05-23 01:56:30 +04:00
|
|
|
{
|
|
|
|
Clear();
|
|
|
|
if (mArray != &(mAutoArray[0])) {
|
|
|
|
delete[] mArray;
|
|
|
|
mArray = &(mAutoArray[0]);
|
|
|
|
mArraySize = kAutoArraySize;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-07-15 08:48:32 +04:00
|
|
|
#if 0
|
1999-02-23 11:10:24 +03:00
|
|
|
NS_IMETHODIMP_(nsISupportsArray&)
|
|
|
|
nsISupportsArray::operator=(const nsISupportsArray& other)
|
1998-05-23 01:56:30 +04:00
|
|
|
{
|
1999-02-23 11:10:24 +03:00
|
|
|
NS_ASSERTION(0, "should be an abstract method");
|
|
|
|
return *this; // bogus
|
|
|
|
}
|
1999-07-15 08:48:32 +04:00
|
|
|
#endif
|
1999-02-23 11:10:24 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP_(nsISupportsArray&)
|
1999-06-02 06:06:32 +04:00
|
|
|
nsSupportsArray::operator=(nsISupportsArray const& aOther)
|
1999-02-23 11:10:24 +03:00
|
|
|
{
|
1999-05-13 08:56:04 +04:00
|
|
|
PRUint32 otherCount = 0;
|
1999-06-02 06:06:32 +04:00
|
|
|
nsresult rv = ((nsISupportsArray&)aOther).Count(&otherCount);
|
1999-05-13 08:56:04 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "this method should return an error!");
|
1999-06-27 10:30:59 +04:00
|
|
|
if (NS_FAILED(rv)) return *this;
|
|
|
|
|
1999-03-21 22:26:32 +03:00
|
|
|
if (otherCount > mArraySize) {
|
1998-05-23 01:56:30 +04:00
|
|
|
DeleteArray();
|
|
|
|
mArraySize = otherCount;
|
|
|
|
mArray = new nsISupports*[mArraySize];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Clear();
|
|
|
|
}
|
|
|
|
mCount = otherCount;
|
1999-02-23 11:10:24 +03:00
|
|
|
while (0 < otherCount--) {
|
1999-06-02 06:06:32 +04:00
|
|
|
mArray[otherCount] = ((nsISupportsArray&)aOther).ElementAt(otherCount);
|
1998-05-23 01:56:30 +04:00
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
1999-02-23 11:10:24 +03:00
|
|
|
NS_IMETHODIMP_(PRBool)
|
1999-06-02 06:06:32 +04:00
|
|
|
nsSupportsArray::Equals(const nsISupportsArray* aOther)
|
1998-05-23 01:56:30 +04:00
|
|
|
{
|
|
|
|
if (0 != aOther) {
|
1999-02-23 11:10:24 +03:00
|
|
|
const nsSupportsArray* other = (const nsSupportsArray*)aOther;
|
1998-05-23 01:56:30 +04:00
|
|
|
if (mCount == other->mCount) {
|
1999-06-02 06:06:32 +04:00
|
|
|
PRUint32 aIndex = mCount;
|
|
|
|
while (0 < aIndex--) {
|
|
|
|
if (mArray[aIndex] != other->mArray[aIndex]) {
|
1998-05-23 01:56:30 +04:00
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
1999-02-23 11:10:24 +03:00
|
|
|
NS_IMETHODIMP_(nsISupports*)
|
1999-06-02 06:06:32 +04:00
|
|
|
nsSupportsArray::ElementAt(PRUint32 aIndex)
|
1998-05-23 01:56:30 +04:00
|
|
|
{
|
1999-07-17 07:28:41 +04:00
|
|
|
if (aIndex < mCount) {
|
1998-05-23 01:56:30 +04:00
|
|
|
nsISupports* element = mArray[aIndex];
|
|
|
|
NS_ADDREF(element);
|
|
|
|
return element;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1999-02-23 11:10:24 +03:00
|
|
|
NS_IMETHODIMP_(PRInt32)
|
1999-06-02 06:06:32 +04:00
|
|
|
nsSupportsArray::IndexOf(const nsISupports* aPossibleElement)
|
|
|
|
{
|
|
|
|
return IndexOfStartingAt(aPossibleElement, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP_(PRInt32)
|
|
|
|
nsSupportsArray::IndexOfStartingAt(const nsISupports* aPossibleElement,
|
|
|
|
PRUint32 aStartIndex)
|
1998-05-23 01:56:30 +04:00
|
|
|
{
|
1999-07-17 07:28:41 +04:00
|
|
|
if (aStartIndex < mCount) {
|
1998-05-23 01:56:30 +04:00
|
|
|
const nsISupports** start = (const nsISupports**)mArray; // work around goofy compiler behavior
|
|
|
|
const nsISupports** ep = (start + aStartIndex);
|
|
|
|
const nsISupports** end = (start + mCount);
|
|
|
|
while (ep < end) {
|
|
|
|
if (aPossibleElement == *ep) {
|
|
|
|
return (ep - start);
|
|
|
|
}
|
|
|
|
ep++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
1999-02-23 11:10:24 +03:00
|
|
|
NS_IMETHODIMP_(PRInt32)
|
1999-06-02 06:06:32 +04:00
|
|
|
nsSupportsArray::LastIndexOf(const nsISupports* aPossibleElement)
|
1998-05-23 01:56:30 +04:00
|
|
|
{
|
|
|
|
if (0 < mCount) {
|
|
|
|
const nsISupports** start = (const nsISupports**)mArray; // work around goofy compiler behavior
|
|
|
|
const nsISupports** ep = (start + mCount);
|
|
|
|
while (start <= --ep) {
|
|
|
|
if (aPossibleElement == *ep) {
|
|
|
|
return (ep - start);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
1999-02-23 11:10:24 +03:00
|
|
|
NS_IMETHODIMP_(PRBool)
|
|
|
|
nsSupportsArray::InsertElementAt(nsISupports* aElement, PRUint32 aIndex)
|
1998-05-23 01:56:30 +04:00
|
|
|
{
|
1999-08-09 00:33:27 +04:00
|
|
|
if (!aElement) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
1999-07-17 07:28:41 +04:00
|
|
|
if (aIndex <= mCount) {
|
1998-05-23 01:56:30 +04:00
|
|
|
if (mArraySize < (mCount + 1)) { // need to grow the array
|
|
|
|
mArraySize += kGrowArrayBy;
|
|
|
|
nsISupports** oldArray = mArray;
|
|
|
|
mArray = new nsISupports*[mArraySize];
|
|
|
|
if (0 == mArray) { // ran out of memory
|
|
|
|
mArray = oldArray;
|
|
|
|
mArraySize -= kGrowArrayBy;
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
if (0 != oldArray) { // need to move old data
|
|
|
|
if (0 < aIndex) {
|
|
|
|
::memcpy(mArray, oldArray, aIndex * sizeof(nsISupports*));
|
|
|
|
}
|
1999-02-23 11:10:24 +03:00
|
|
|
PRUint32 slide = (mCount - aIndex);
|
1998-05-23 01:56:30 +04:00
|
|
|
if (0 < slide) {
|
|
|
|
::memcpy(mArray + aIndex + 1, oldArray + aIndex, slide * sizeof(nsISupports*));
|
|
|
|
}
|
|
|
|
if (oldArray != &(mAutoArray[0])) {
|
|
|
|
delete[] oldArray;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
1999-02-23 11:10:24 +03:00
|
|
|
PRUint32 slide = (mCount - aIndex);
|
1998-05-23 01:56:30 +04:00
|
|
|
if (0 < slide) {
|
|
|
|
::memmove(mArray + aIndex + 1, mArray + aIndex, slide * sizeof(nsISupports*));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mArray[aIndex] = aElement;
|
|
|
|
NS_ADDREF(aElement);
|
|
|
|
mCount++;
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
1999-02-23 11:10:24 +03:00
|
|
|
NS_IMETHODIMP_(PRBool)
|
|
|
|
nsSupportsArray::ReplaceElementAt(nsISupports* aElement, PRUint32 aIndex)
|
1998-05-23 01:56:30 +04:00
|
|
|
{
|
1999-07-17 07:28:41 +04:00
|
|
|
if (aIndex < mCount) {
|
1998-05-23 01:56:30 +04:00
|
|
|
NS_ADDREF(aElement); // addref first in case it's the same object!
|
|
|
|
NS_RELEASE(mArray[aIndex]);
|
|
|
|
mArray[aIndex] = aElement;
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
1999-02-23 11:10:24 +03:00
|
|
|
NS_IMETHODIMP_(PRBool)
|
|
|
|
nsSupportsArray::RemoveElementAt(PRUint32 aIndex)
|
1998-05-23 01:56:30 +04:00
|
|
|
{
|
1999-07-17 07:28:41 +04:00
|
|
|
if (aIndex < mCount) {
|
1998-05-23 01:56:30 +04:00
|
|
|
NS_RELEASE(mArray[aIndex]);
|
|
|
|
mCount--;
|
|
|
|
PRInt32 slide = (mCount - aIndex);
|
|
|
|
if (0 < slide) {
|
|
|
|
::memmove(mArray + aIndex, mArray + aIndex + 1,
|
|
|
|
slide * sizeof(nsISupports*));
|
|
|
|
}
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
1999-02-23 11:10:24 +03:00
|
|
|
NS_IMETHODIMP_(PRBool)
|
|
|
|
nsSupportsArray::RemoveElement(const nsISupports* aElement, PRUint32 aStartIndex)
|
1998-05-23 01:56:30 +04:00
|
|
|
{
|
1999-07-17 07:28:41 +04:00
|
|
|
if (aStartIndex < mCount) {
|
1998-05-23 01:56:30 +04:00
|
|
|
nsISupports** ep = mArray;
|
|
|
|
nsISupports** end = ep + mCount;
|
|
|
|
while (ep < end) {
|
|
|
|
if (*ep == aElement) {
|
1999-02-23 11:10:24 +03:00
|
|
|
return RemoveElementAt(PRUint32(ep - mArray));
|
1998-05-23 01:56:30 +04:00
|
|
|
}
|
|
|
|
ep++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
1999-02-23 11:10:24 +03:00
|
|
|
NS_IMETHODIMP_(PRBool)
|
|
|
|
nsSupportsArray::RemoveLastElement(const nsISupports* aElement)
|
1998-05-23 01:56:30 +04:00
|
|
|
{
|
|
|
|
if (0 < mCount) {
|
|
|
|
nsISupports** ep = (mArray + mCount);
|
|
|
|
while (mArray <= --ep) {
|
|
|
|
if (*ep == aElement) {
|
1999-02-23 11:10:24 +03:00
|
|
|
return RemoveElementAt(PRUint32(ep - mArray));
|
1998-05-23 01:56:30 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
1999-02-23 11:10:24 +03:00
|
|
|
NS_IMETHODIMP_(PRBool)
|
|
|
|
nsSupportsArray::AppendElements(nsISupportsArray* aElements)
|
1998-11-03 23:14:08 +03:00
|
|
|
{
|
1999-02-23 11:10:24 +03:00
|
|
|
nsSupportsArray* elements = (nsSupportsArray*)aElements;
|
1998-11-03 23:14:08 +03:00
|
|
|
|
|
|
|
if (elements && (0 < elements->mCount)) {
|
|
|
|
if (mArraySize < (mCount + elements->mCount)) { // need to grow the array
|
1999-02-23 11:10:24 +03:00
|
|
|
PRUint32 count = mCount + elements->mCount;
|
|
|
|
PRUint32 oldSize = mArraySize;
|
1998-11-03 23:14:08 +03:00
|
|
|
while (mArraySize < count) { // ick
|
|
|
|
mArraySize += kGrowArrayBy;
|
|
|
|
}
|
|
|
|
nsISupports** oldArray = mArray;
|
|
|
|
mArray = new nsISupports*[mArraySize];
|
|
|
|
if (0 == mArray) { // ran out of memory
|
|
|
|
mArray = oldArray;
|
|
|
|
mArraySize = oldSize;
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
if (0 != oldArray) { // need to move old data
|
|
|
|
if (0 < mCount) {
|
1999-07-09 19:05:18 +04:00
|
|
|
::memcpy(mArray, oldArray, mCount * sizeof(nsISupports*));
|
1998-11-03 23:14:08 +03:00
|
|
|
}
|
|
|
|
if (oldArray != &(mAutoArray[0])) {
|
|
|
|
delete[] oldArray;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-06-02 06:06:32 +04:00
|
|
|
PRUint32 aIndex = 0;
|
|
|
|
while (aIndex < elements->mCount) {
|
|
|
|
NS_ADDREF(elements->mArray[aIndex]);
|
|
|
|
mArray[mCount++] = elements->mArray[aIndex++];
|
1998-11-03 23:14:08 +03:00
|
|
|
}
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
1999-02-23 11:10:24 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSupportsArray::Clear(void)
|
1998-05-23 01:56:30 +04:00
|
|
|
{
|
1999-02-24 02:31:49 +03:00
|
|
|
if (0 < mCount) {
|
|
|
|
do {
|
|
|
|
--mCount;
|
|
|
|
NS_RELEASE(mArray[mCount]);
|
|
|
|
} while (0 != mCount);
|
1998-05-23 01:56:30 +04:00
|
|
|
}
|
1999-02-23 11:10:24 +03:00
|
|
|
return NS_OK;
|
1998-05-23 01:56:30 +04:00
|
|
|
}
|
|
|
|
|
1999-06-02 06:06:32 +04:00
|
|
|
NS_IMETHODIMP
|
1999-02-23 11:10:24 +03:00
|
|
|
nsSupportsArray::Compact(void)
|
1998-05-23 01:56:30 +04:00
|
|
|
{
|
|
|
|
if ((mArraySize != mCount) && (kAutoArraySize < mArraySize)) {
|
|
|
|
nsISupports** oldArray = mArray;
|
1999-02-23 11:10:24 +03:00
|
|
|
PRUint32 oldArraySize = mArraySize;
|
1998-05-23 01:56:30 +04:00
|
|
|
if (mCount <= kAutoArraySize) {
|
|
|
|
mArray = &(mAutoArray[0]);
|
|
|
|
mArraySize = kAutoArraySize;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mArray = new nsISupports*[mCount];
|
|
|
|
mArraySize = mCount;
|
|
|
|
}
|
|
|
|
if (0 == mArray) {
|
|
|
|
mArray = oldArray;
|
|
|
|
mArraySize = oldArraySize;
|
1999-06-02 06:06:32 +04:00
|
|
|
return NS_OK;
|
1998-05-23 01:56:30 +04:00
|
|
|
}
|
|
|
|
::memcpy(mArray, oldArray, mCount * sizeof(nsISupports*));
|
|
|
|
delete[] oldArray;
|
|
|
|
}
|
1999-06-02 06:06:32 +04:00
|
|
|
return NS_OK;
|
1998-05-23 01:56:30 +04:00
|
|
|
}
|
|
|
|
|
1999-02-23 11:10:24 +03:00
|
|
|
NS_IMETHODIMP_(PRBool)
|
1999-06-02 06:06:32 +04:00
|
|
|
nsSupportsArray::EnumerateForwards(nsISupportsArrayEnumFunc aFunc, void* aData)
|
1998-05-23 01:56:30 +04:00
|
|
|
{
|
1999-06-02 06:06:32 +04:00
|
|
|
PRInt32 aIndex = -1;
|
1998-05-23 01:56:30 +04:00
|
|
|
PRBool running = PR_TRUE;
|
|
|
|
|
1999-06-02 06:06:32 +04:00
|
|
|
while (running && (++aIndex < (PRInt32)mCount)) {
|
|
|
|
running = (*aFunc)(mArray[aIndex], aData);
|
1998-05-23 01:56:30 +04:00
|
|
|
}
|
|
|
|
return running;
|
|
|
|
}
|
|
|
|
|
1999-02-23 11:10:24 +03:00
|
|
|
NS_IMETHODIMP_(PRBool)
|
1999-06-02 06:06:32 +04:00
|
|
|
nsSupportsArray::EnumerateBackwards(nsISupportsArrayEnumFunc aFunc, void* aData)
|
1998-05-23 01:56:30 +04:00
|
|
|
{
|
1999-06-02 06:06:32 +04:00
|
|
|
PRUint32 aIndex = mCount;
|
1998-05-23 01:56:30 +04:00
|
|
|
PRBool running = PR_TRUE;
|
|
|
|
|
1999-06-02 06:06:32 +04:00
|
|
|
while (running && (0 < aIndex--)) {
|
|
|
|
running = (*aFunc)(mArray[aIndex], aData);
|
1998-05-23 01:56:30 +04:00
|
|
|
}
|
|
|
|
return running;
|
|
|
|
}
|
|
|
|
|
1999-02-23 11:10:24 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSupportsArray::Enumerate(nsIEnumerator* *result)
|
|
|
|
{
|
|
|
|
nsSupportsArrayEnumerator* e = new nsSupportsArrayEnumerator(this);
|
|
|
|
if (!e)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
*result = e;
|
|
|
|
NS_ADDREF(e);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-05-23 01:56:30 +04:00
|
|
|
|
2000-06-09 11:51:13 +04:00
|
|
|
static PRBool
|
|
|
|
CopyElement(nsISupports* aElement, void *aData)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
nsISupportsArray* newArray = (nsISupportsArray*)aData;
|
|
|
|
rv = newArray->AppendElement(aElement);
|
|
|
|
return NS_SUCCEEDED(rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSupportsArray::Clone(nsISupportsArray* *result)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
nsISupportsArray* newArray;
|
|
|
|
rv = NS_NewISupportsArray(&newArray);
|
|
|
|
PRBool ok = EnumerateForwards(CopyElement, newArray);
|
|
|
|
if (!ok) return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
*result = newArray;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-05-23 01:56:30 +04:00
|
|
|
NS_COM nsresult
|
1999-02-23 11:10:24 +03:00
|
|
|
NS_NewISupportsArray(nsISupportsArray** aInstancePtrResult)
|
1998-05-23 01:56:30 +04:00
|
|
|
{
|
1999-05-26 05:38:36 +04:00
|
|
|
nsresult rv;
|
1999-12-01 02:36:32 +03:00
|
|
|
rv = nsSupportsArray::Create(NULL, NS_GET_IID(nsISupportsArray),
|
1999-05-26 05:38:36 +04:00
|
|
|
(void**)aInstancePtrResult);
|
|
|
|
return rv;
|
1998-05-23 01:56:30 +04:00
|
|
|
}
|
|
|
|
|