Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions
nsMemory Class Reference

Static helper routines to manage memory. More...

#include <nsMemory.h>

List of all members.

Public Member Functions

static PRSize size return NS_Realloc (ptr, size)

Static Public Member Functions

static NS_HIDDEN_ (void *) Alloc(size_t size)
static NS_HIDDEN_ (void *) Realloc(void *ptr
static NS_HIDDEN_ (void) Free(void *ptr)
static NS_COM_GLUE nsresult HeapMinimize (PRBool aImmediate)
static NS_COM_GLUE voidClone (const void *ptr, PRSize size)
static NS_COM_GLUE nsIMemoryGetGlobalMemoryService ()

Detailed Description

Static helper routines to manage memory.

These routines allow easy access to xpcom's built-in (global) nsIMemory implementation, without needing to go through the service manager to get it. However this requires clients to link with the xpcom DLL.

This class is not threadsafe and is intented for use only on the main thread.

Definition at line 64 of file nsMemory.h.


Member Function Documentation

NS_COM_GLUE void * nsMemory::Clone ( const void ptr,
PRSize  size 
) [static]

Definition at line 59 of file nsMemory.cpp.

{
    void* newPtr = NS_Alloc(size);
    if (newPtr)
        memcpy(newPtr, ptr, size);
    return newPtr;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 68 of file nsMemory.cpp.

{
    nsIMemory* mem;
    nsresult rv = NS_GetMemoryManager(&mem);
    if (NS_FAILED(rv)) return nsnull;
   
    return mem;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 49 of file nsMemory.cpp.

{
    nsCOMPtr<nsIMemory> mem;
    nsresult rv = NS_GetMemoryManager(getter_AddRefs(mem));
    NS_ENSURE_SUCCESS(rv, rv);

    return mem->HeapMinimize(aImmediate);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsMemory::NS_HIDDEN_ ( void ) [inline, static]

Definition at line 67 of file nsMemory.h.

        { return NS_Alloc(size); }

Here is the call graph for this function:

static nsMemory::NS_HIDDEN_ ( void ) [static]
static nsMemory::NS_HIDDEN_ ( void  ) [inline, static]

Definition at line 73 of file nsMemory.h.

        { NS_Free(ptr); }

Here is the call graph for this function:


The documentation for this class was generated from the following files: