Changeset 101852 in vbox
- Timestamp:
- Nov 6, 2023 11:09:45 AM (15 months ago)
- Location:
- trunk/src/libs/xpcom18a4
- Files:
-
- 3 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/xpcom18a4/Config.kmk
r101836 r101852 373 373 xpcom/base/nsIDebug.idl \ 374 374 xpcom/base/nsIInterfaceRequestor.idl \ 375 xpcom/base/nsIMemory.idl \376 375 xpcom/base/nsIProgrammingLanguage.idl \ 377 376 xpcom/base/nsISupports.idl \ -
trunk/src/libs/xpcom18a4/Makefile.kmk
r101851 r101852 580 580 xpcom/base/nsExceptionService.cpp \ 581 581 xpcom/base/nsID.cpp \ 582 xpcom/base/nsMemoryImpl.cpp \583 582 xpcom/base/nsTraceRefcntImpl.cpp 584 583 $(evalcall VBOX_XPCOM_X86,VBox-xpcom-base) … … 1126 1125 nsIDebug.xpt \ 1127 1126 nsIInterfaceRequestor.xpt \ 1128 nsIMemory.xpt \1129 1127 nsIProgrammingLanguage.xpt \ 1130 1128 nsISupports.xpt \ -
trunk/src/libs/xpcom18a4/xpcom/build/nsXPCOM.h
r101846 r101852 171 171 172 172 /** 173 * Public Method to access to the memory manager. See nsIMemory174 *175 * @status FROZEN176 * @param result Interface pointer to the memory manager177 *178 * @return NS_OK for success;179 * other error codes indicate a failure during initialisation.180 *181 */182 extern "C" NS_COM nsresult183 NS_GetMemoryManager(nsIMemory* *result);184 185 /**186 173 * Public Method to create an instance of a nsILocalFile. This function 187 174 * may be called prior to NS_InitXPCOM2. -
trunk/src/libs/xpcom18a4/xpcom/build/nsXPComInit.cpp
r101846 r101852 48 48 #include "nsBinaryStream.h" 49 49 50 #include "nsMemoryImpl.h"51 50 #include "nsDebugImpl.h" 52 51 #include "nsTraceRefcntImpl.h" … … 124 123 125 124 static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); 126 static NS_DEFINE_CID(kMemoryCID, NS_MEMORY_CID);127 125 static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); 128 126 … … 326 324 327 325 static const nsModuleComponentInfo components[] = { 328 COMPONENT(MEMORY, nsMemoryImpl::Create),329 326 COMPONENT(DEBUG, nsDebugImpl::Create), 330 327 #define NS_ERRORSERVICE_CLASSNAME NS_ERRORSERVICE_NAME … … 420 417 const int components_length = sizeof(components) / sizeof(components[0]); 421 418 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 437 419 // gDebug will be freed during shutdown. 438 420 static nsIDebug* gDebug = nsnull; … … 500 482 // Establish the main thread here. 501 483 rv = nsIThread::SetMainThread(); 502 if (NS_FAILED(rv)) return rv;503 504 // Startup the memory manager505 rv = nsMemoryImpl::Startup();506 484 if (NS_FAILED(rv)) return rv; 507 485 … … 586 564 } 587 565 } 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;594 566 595 567 rv = compMgr->RegisterService(kComponentManagerCID, NS_STATIC_CAST(nsIComponentManager*, compMgr)); … … 914 886 915 887 EmptyEnumeratorImpl::Shutdown(); 916 nsMemoryImpl::Shutdown();917 NS_IF_RELEASE(gMemory);918 888 919 889 nsThread::Shutdown(); -
trunk/src/libs/xpcom18a4/xpcom/glue/nsMemory.cpp
r5522 r101852 36 36 * ***** END LICENSE BLOCK ***** */ 37 37 38 #include "nsXPCOM.h"39 38 #include "nsMemory.h" 40 #include "nsXPCOMPrivate.h"41 39 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> 87 41 88 42 //////////////////////////////////////////////////////////////////////////////// … … 92 46 nsMemory::Alloc(PRSize size) 93 47 { 94 if (!ENSURE_ALLOCATOR) 95 return nsnull; 96 97 return gMemory->Alloc(size); 48 return RTMemAlloc(size); 98 49 } 99 50 … … 101 52 nsMemory::Realloc(void* ptr, PRSize size) 102 53 { 103 if (!ENSURE_ALLOCATOR) 104 return nsnull; 105 106 return gMemory->Realloc(ptr, size); 54 return RTMemRealloc(ptr, size); 107 55 } 108 56 … … 110 58 nsMemory::Free(void* ptr) 111 59 { 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); 125 61 } 126 62 … … 128 64 nsMemory::Clone(const void* ptr, PRSize size) 129 65 { 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); 148 67 } 149 68 -
trunk/src/libs/xpcom18a4/xpcom/glue/nsMemory.h
r1 r101852 39 39 #define nsMemory_h__ 40 40 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" 52 42 53 43 … … 67 57 static NS_COM void* Realloc(void* ptr, size_t size); 68 58 static NS_COM void Free(void* ptr); 69 static NS_COM nsresult HeapMinimize(PRBool aImmediate);70 59 static NS_COM void* Clone(const void* ptr, size_t size); 71 static NS_COM nsIMemory* GetGlobalMemoryService(); // AddRefs72 60 }; 73 61
Note:
See TracChangeset
for help on using the changeset viewer.