#include <nsMemory.h>
#include <stdlib.h>
Go to the source code of this file.
|
#define | SB_AUTO_CLASS2(aName, aType, aType2, aIsValid, aDispose, aInvalidate) |
|
#define | SB_AUTO_CLASS(aName, aType, aIsValid, aDispose, aInvalidate) SB_AUTO_CLASS2(aName, aType, char, aIsValid, aDispose, aInvalidate) |
|
#define | SB_AUTO_NULL_CLASS(aName, aType, aDispose) SB_AUTO_CLASS(aName, aType, mValue != NULL, aDispose, mValue = NULL) |
|
|
template<class COMPtr , class ReturnType > |
nsresult | sbReturnCOMPtr (COMPtr &aPtr, ReturnType **aReturn) |
|
void * | SB_CloneMemory (const void *ptr, PRSize size) |
| Clone a block of contiguous memory. More...
|
|
#define SB_AUTO_CLASS |
( |
|
aName, |
|
|
|
aType, |
|
|
|
aIsValid, |
|
|
|
aDispose, |
|
|
|
aInvalidate |
|
) |
| SB_AUTO_CLASS2(aName, aType, char, aIsValid, aDispose, aInvalidate) |
#define SB_AUTO_CLASS2 |
( |
|
aName, |
|
|
|
aType, |
|
|
|
aType2, |
|
|
|
aIsValid, |
|
|
|
aDispose, |
|
|
|
aInvalidate |
|
) |
| |
Define a class that wraps a data type and auto-disposes it when going out of scope. The class name is specified by aName, and the data type is specified by aType. An additional class field type may be specified by aType2. A code snippet that checks for valid data is specified by aIsValid. A code snippet that disposes of the data is specified by aDispose. A code snippet that invalidates the data is specified by aInvalidate. The code snippets may use mValue to refer to the wrapped data and mValue2 to refer to the additional class field.
- Parameters
-
aName | Name of class. |
aType | Class data type. |
aType2 | Additional class field data type. |
aIsValid | Code snippet to test for data validity. |
aDispose | Code snippet to dispose of the data. |
aInvalidate | Code snippet to invalidate the data. |
Example: SB_AUTO_CLASS(sbAutoMemPtr, void*, !!mValue, NS_Free(mValue), mValue = nsnull) sbAutoMemPtr autoMem(memPtr);
SB_AUTO_CLASS2(sbAutoClassData, void*, classType*, !!mValue, mValue2->Delete(mValue), mValue = nsnull) sbAutoClassData(data, this);
Definition at line 135 of file sbMemoryUtils.h.
#define SB_AUTO_NULL_CLASS |
( |
|
aName, |
|
|
|
aType, |
|
|
|
aDispose |
|
) |
| SB_AUTO_CLASS(aName, aType, mValue != NULL, aDispose, mValue = NULL) |
Define an auto-disposal class wrapper for data types whose invalid value is NULL.
- Parameters
-
aName | Name of class. |
aType | Class data type. |
aDispose | Code snippet to dispose of the data. |
Definition at line 231 of file sbMemoryUtils.h.
void* SB_CloneMemory |
( |
const void * |
ptr, |
|
|
PRSize |
size |
|
) |
| |
|
inline |
template<class COMPtr , class ReturnType >
nsresult sbReturnCOMPtr |
( |
COMPtr & |
aPtr, |
|
|
ReturnType ** |
aReturn |
|
) |
| |
|
inline |