Allocates and frees memory.
The csIMalloc interface implements six methods:
Allocates and initializes memory for a number of objects. |
|
Frees memory that is no longer in use. |
|
Frees memory, allowing a NULL pointer. |
|
Confirms that the interface was found and registered. |
|
Allocates an amount of memory. |
|
Reallocates previously allocated memory. |
Plug-in modules can use this object to take advantage of the server’s efficient memory allocation technique. The object is valid for the full lifetime of the client, so Init does not return a reference.
Allocates, and initializes to zero, memory for a number of objects.
void* Calloc (PRUint32 aSize, PPRUint32 aNum)=0;
The method has the following two parameters:
aSize |
The size in bytes of each object. |
nNum |
The number of objects. |
A pointer to the allocated memory on success, or NULL on failure.
This method allocates enough memory for the specified number of objects of the specified size, and initializes the memory to zero.
Free memory previously allocated by the Malloc method.
PRUint32 Free (void * aPtr)=0;
The method has the following parameter:
aPtr |
A pointer to the memory to be freed. |
NS_OK on success, non-zero error code on failure.
Use this method in the same way as its C or C++ counterpart to free previously allocated memory.
Free memory previously allocated by the Malloc method, allowing a NULL pointer.
PRUint32 FreeIf (void * aPtr)=0;
The method has the following parameter:
aPtr |
A pointer to the memory to be freed or NULL. |
NS_OK on success, non-zero error code on failure.
Frees the memory at the specified location, if aPtr is not NULL.
Confirm that the interface has been registered.
PRUint32 Init() = 0;
The method has no parameters.
NS_OK on success, non-zero error code on failure.
The server calls this method to confirm that the interface was found and registered successfully.
Allocate a specified amount of memory.
void* Malloc (PRUint32 nBytes)=0;
The method has the following parameter:
nBytes |
The size in bytes of the memory to be allocated. |
A pointer to the allocated memory on success, or NULL on failure.
Use this method in the same way as its C or C++ counterpart.
Reallocates memory that was previously allocated.
void* Realloc (void* aPtr,PRUint32 nBytes)=0;
The method has the following parameter:
aPtr |
A pointer to previously allocated memory. |
nBytes |
The size in bytes of the memory to be allocated. |
A pointer to the allocated memory on success, or NULL on failure.
Use this method in the same way as its C or C++ counterpart to reallocate memory that was previously allocated.