Bug 225507: Implement nsCOMArray::SafeObjectAt for out-of-bounds safe access.

r=bryner sr=alecf
This commit is contained in:
sicking%bigfoot.com 2005-11-02 16:05:15 +00:00
Родитель f777369283
Коммит 932310909a
1 изменённых файлов: 9 добавлений и 0 удалений

Просмотреть файл

@ -100,6 +100,10 @@ public:
return NS_STATIC_CAST(nsISupports*, mArray.ElementAt(aIndex));
}
nsISupports* SafeObjectAt(PRInt32 aIndex) const {
return NS_STATIC_CAST(nsISupports*, mArray.SafeElementAt(aIndex));
}
nsISupports* operator[](PRInt32 aIndex) const {
return ObjectAt(aIndex);
}
@ -149,6 +153,11 @@ class nsCOMArray : public nsCOMArray_base
return NS_STATIC_CAST(T*,nsCOMArray_base::ObjectAt(aIndex));
}
// these do NOT refcount on the way out, for speed
T* SafeObjectAt(PRInt32 aIndex) const {
return NS_STATIC_CAST(T*,nsCOMArray_base::SafeObjectAt(aIndex));
}
// indexing operator for syntactic sugar
T* operator[](PRInt32 aIndex) const {
return ObjectAt(aIndex);