25 #ifndef __SBMEMORYUTILS_H__
26 #define __SBMEMORYUTILS_H__
42 NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(mCount, mArray);
63 NS_ASSERTION(aArray,
"Null pointer!");
69 NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(mCount, mArray);
86 NS_ASSERTION(aArray,
"Null pointer!");
92 NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(mCount, mArray);
135 #define SB_AUTO_CLASS2(aName, aType, aType2, aIsValid, aDispose, aInvalidate) \
139 aName() { Invalidate(); } \
141 aName(aType aValue) : mValue(aValue) {} \
143 aName(aType aValue, aType2 aValue2) : mValue(aValue), mValue2(aValue2) {} \
152 void Set(aType aValue) { mValue = aValue; } \
154 void Set(aType aValue, aType2 aValue2) \
155 { mValue = aValue; mValue2 = aValue2; } \
159 aType value = mValue; \
169 operator aType() const \
174 aType& operator=(aType aValue) \
181 aType operator->() const \
185 "Cannot dereference an invalid auto class with operator->()."); \
204 aType* StartAssignment() \
207 return reinterpret_cast<aType*>(&mValue); \
214 void Invalidate() { aInvalidate; } \
215 void operator=(const aName aValue) {} \
218 #define SB_AUTO_CLASS(aName, aType, aIsValid, aDispose, aInvalidate) \
219 SB_AUTO_CLASS2(aName, aType, char, aIsValid, aDispose, aInvalidate)
231 #define SB_AUTO_NULL_CLASS(aName, aType, aDispose) \
232 SB_AUTO_CLASS(aName, aType, mValue != NULL, aDispose, mValue = NULL)
267 for (PRUint32
i = 0;
i < mValue2; ++
i) {
276 template <
class COMPtr,
class ReturnType>
281 return NS_ERROR_INVALID_POINTER;
284 *aReturn = aPtr.get();
285 NS_IF_ADDREF(*aReturn);
295 void* newPtr = NS_Alloc(size);
297 memcpy(newPtr, ptr, size);
sbAutoFreeXPCOMPointerArray(PRUint32 aCount, T **aArray)
void * SB_CloneMemory(const void *ptr, PRSize size)
Clone a block of contiguous memory.
#define SB_AUTO_NULL_CLASS(aName, aType, aDispose)
nsresult sbReturnCOMPtr(COMPtr &aPtr, ReturnType **aReturn)
sbAutoFreeXPCOMArrayByRef(PRUint32 &aCount, T &aArray)
sbAutoFreeXPCOMArray(PRUint32 aCount, T aArray)
#define SB_AUTO_CLASS(aName, aType, aIsValid, aDispose, aInvalidate)
~sbAutoFreeXPCOMArrayByRef()
~sbAutoFreeXPCOMPointerArray()
#define SB_AUTO_CLASS2(aName, aType, aType2, aIsValid, aDispose, aInvalidate)
restoreHistoryPrecursor aCount
_getSelectedPageStyle s i