VirtualBox

Changeset 101852 in vbox


Ignore:
Timestamp:
Nov 6, 2023 11:09:45 AM (15 months ago)
Author:
vboxsync
Message:

libs/xpcom: Get rid of nsMemoryImpl.{cpp,h} and nsIMemory and repalce it with direct calls to RTMem* APIs, bugref:10545

Location:
trunk/src/libs/xpcom18a4
Files:
3 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/Config.kmk

    r101836 r101852  
    373373        xpcom/base/nsIDebug.idl \
    374374        xpcom/base/nsIInterfaceRequestor.idl \
    375         xpcom/base/nsIMemory.idl \
    376375        xpcom/base/nsIProgrammingLanguage.idl \
    377376        xpcom/base/nsISupports.idl \
  • trunk/src/libs/xpcom18a4/Makefile.kmk

    r101851 r101852  
    580580        xpcom/base/nsExceptionService.cpp \
    581581        xpcom/base/nsID.cpp \
    582         xpcom/base/nsMemoryImpl.cpp \
    583582        xpcom/base/nsTraceRefcntImpl.cpp
    584583$(evalcall VBOX_XPCOM_X86,VBox-xpcom-base)
     
    11261125                nsIDebug.xpt \
    11271126                nsIInterfaceRequestor.xpt \
    1128                 nsIMemory.xpt \
    11291127                nsIProgrammingLanguage.xpt \
    11301128                nsISupports.xpt \
  • trunk/src/libs/xpcom18a4/xpcom/build/nsXPCOM.h

    r101846 r101852  
    171171
    172172/**
    173  * Public Method to access to the memory manager.  See nsIMemory
    174  *
    175  * @status FROZEN
    176  * @param result Interface pointer to the memory manager
    177  *
    178  * @return NS_OK for success;
    179  *         other error codes indicate a failure during initialisation.
    180  *
    181  */
    182 extern "C" NS_COM nsresult
    183 NS_GetMemoryManager(nsIMemory* *result);
    184 
    185 /**
    186173 * Public Method to create an instance of a nsILocalFile.  This function
    187174 * may be called prior to NS_InitXPCOM2. 
  • trunk/src/libs/xpcom18a4/xpcom/build/nsXPComInit.cpp

    r101846 r101852  
    4848#include "nsBinaryStream.h"
    4949
    50 #include "nsMemoryImpl.h"
    5150#include "nsDebugImpl.h"
    5251#include "nsTraceRefcntImpl.h"
     
    124123
    125124static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
    126 static NS_DEFINE_CID(kMemoryCID, NS_MEMORY_CID);
    127125static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
    128126
     
    326324
    327325static const nsModuleComponentInfo components[] = {
    328     COMPONENT(MEMORY, nsMemoryImpl::Create),
    329326    COMPONENT(DEBUG,  nsDebugImpl::Create),
    330327#define NS_ERRORSERVICE_CLASSNAME NS_ERRORSERVICE_NAME
     
    420417const int components_length = sizeof(components) / sizeof(components[0]);
    421418
    422 // gMemory will be freed during shutdown.
    423 static nsIMemory* gMemory = nsnull;
    424 nsresult NS_COM NS_GetMemoryManager(nsIMemory* *result)
    425 {
    426     nsresult rv = NS_OK;
    427     if (!gMemory)
    428     {
    429         rv = nsMemoryImpl::Create(nsnull,
    430                                   NS_GET_IID(nsIMemory),
    431                                   (void**)&gMemory);
    432     }
    433     NS_IF_ADDREF(*result = gMemory);
    434     return rv;
    435 }
    436 
    437419// gDebug will be freed during shutdown.
    438420static nsIDebug* gDebug = nsnull;
     
    500482    // Establish the main thread here.
    501483    rv = nsIThread::SetMainThread();
    502     if (NS_FAILED(rv)) return rv;
    503 
    504     // Startup the memory manager
    505     rv = nsMemoryImpl::Startup();
    506484    if (NS_FAILED(rv)) return rv;
    507485
     
    586564        }
    587565    }
    588 
    589     nsCOMPtr<nsIMemory> memory;
    590     NS_GetMemoryManager(getter_AddRefs(memory));
    591     // dougt - these calls will be moved into a new interface when nsIComponentManager is frozen.
    592     rv = compMgr->RegisterService(kMemoryCID, memory);
    593     if (NS_FAILED(rv)) return rv;
    594566
    595567    rv = compMgr->RegisterService(kComponentManagerCID, NS_STATIC_CAST(nsIComponentManager*, compMgr));
     
    914886
    915887    EmptyEnumeratorImpl::Shutdown();
    916     nsMemoryImpl::Shutdown();
    917     NS_IF_RELEASE(gMemory);
    918888
    919889    nsThread::Shutdown();
  • trunk/src/libs/xpcom18a4/xpcom/glue/nsMemory.cpp

    r5522 r101852  
    3636 * ***** END LICENSE BLOCK ***** */
    3737
    38 #include "nsXPCOM.h"
    3938#include "nsMemory.h"
    40 #include "nsXPCOMPrivate.h"
    4139
    42 static nsIMemory* gMemory = nsnull;
    43 
    44 static NS_METHOD FreeGlobalMemory(void)
    45 {
    46     NS_ASSERTION(gMemory, "must be not null after SetupGlobalMemory");
    47     NS_IF_RELEASE(gMemory);
    48     return NS_OK;
    49 }
    50 
    51 #define ENSURE_ALLOCATOR \
    52   (gMemory ? PR_TRUE : (PRBool)(SetupGlobalMemory() != nsnull))
    53 
    54 static nsIMemory*
    55 SetupGlobalMemory()
    56 {
    57     NS_ASSERTION(!gMemory, "must be called once");
    58     if (!gMemory)
    59     {
    60         NS_GetMemoryManager(&gMemory);
    61         NS_ASSERTION(gMemory, "can't get memory manager!");
    62         if (gMemory)
    63             NS_RegisterXPCOMExitRoutine(FreeGlobalMemory, 0);
    64     }
    65     return gMemory;
    66 }
    67 
    68 #ifdef XPCOM_GLUE
    69 nsresult GlueStartupMemory()
    70 {
    71     NS_ASSERTION(!gMemory, "must be called once");
    72     if (!gMemory)
    73     {
    74         NS_GetMemoryManager(&gMemory);
    75         NS_ASSERTION(gMemory, "can't get memory manager!");
    76         if (!gMemory)
    77             return NS_ERROR_FAILURE;
    78     }
    79     return NS_OK;
    80 }
    81 
    82 void GlueShutdownMemory()
    83 {
    84     NS_IF_RELEASE(gMemory);
    85 }
    86 #endif
     40#include <iprt/mem.h>
    8741
    8842////////////////////////////////////////////////////////////////////////////////
     
    9246nsMemory::Alloc(PRSize size)
    9347{
    94     if (!ENSURE_ALLOCATOR)
    95         return nsnull;
    96  
    97    return gMemory->Alloc(size);
     48    return RTMemAlloc(size);
    9849}
    9950
     
    10152nsMemory::Realloc(void* ptr, PRSize size)
    10253{
    103     if (!ENSURE_ALLOCATOR)
    104         return nsnull;   
    105 
    106     return gMemory->Realloc(ptr, size);
     54    return RTMemRealloc(ptr, size);
    10755}
    10856
     
    11058nsMemory::Free(void* ptr)
    11159{
    112     if (!ENSURE_ALLOCATOR)
    113         return;   
    114 
    115     gMemory->Free(ptr);
    116 }
    117 
    118 NS_COM nsresult
    119 nsMemory::HeapMinimize(PRBool aImmediate)
    120 {
    121     if (!ENSURE_ALLOCATOR)
    122         return NS_ERROR_FAILURE;   
    123 
    124     return gMemory->HeapMinimize(aImmediate);
     60    RTMemFree(ptr);
    12561}
    12662
     
    12864nsMemory::Clone(const void* ptr, PRSize size)
    12965{
    130     if (!ENSURE_ALLOCATOR)
    131         return nsnull;   
    132 
    133     void* newPtr = gMemory->Alloc(size);
    134     if (newPtr)
    135         memcpy(newPtr, ptr, size);
    136     return newPtr;
    137 }
    138 
    139 NS_COM nsIMemory*
    140 nsMemory::GetGlobalMemoryService()
    141 {
    142     if (!ENSURE_ALLOCATOR)
    143         return nsnull;   
    144    
    145     nsIMemory* result = gMemory;
    146     NS_IF_ADDREF(result);
    147     return result;
     66    return RTMemDup(ptr, size);
    14867}
    14968
  • trunk/src/libs/xpcom18a4/xpcom/glue/nsMemory.h

    r1 r101852  
    3939#define nsMemory_h__
    4040
    41 #include "nsIMemory.h"
    42 
    43 #define NS_MEMORY_CONTRACTID "@mozilla.org/xpcom/memory-service;1"
    44 #define NS_MEMORY_CLASSNAME  "Global Memory Service"
    45 #define NS_MEMORY_CID                                \
    46 { /* 30a04e40-38e7-11d4-8cf5-0060b0fc14a3 */         \
    47     0x30a04e40,                                      \
    48     0x38e7,                                          \
    49     0x11d4,                                          \
    50     {0x8c, 0xf5, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \
    51 }
     41#include "nsISupports.h"
    5242
    5343
     
    6757    static NS_COM void*      Realloc(void* ptr, size_t size);
    6858    static NS_COM void       Free(void* ptr);
    69     static NS_COM nsresult   HeapMinimize(PRBool aImmediate);
    7059    static NS_COM void*      Clone(const void* ptr, size_t size);
    71     static NS_COM nsIMemory* GetGlobalMemoryService();       // AddRefs
    7260};
    7361
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette