Changeset 101996 in vbox for trunk/src/libs/xpcom18a4/ipc/ipcd/extensions/transmngr/common/tmVector.cpp
- Timestamp:
- Nov 8, 2023 5:57:26 PM (13 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/xpcom18a4/ipc/ipcd/extensions/transmngr/common/tmVector.cpp
r31259 r101996 38 38 #include <stdlib.h> 39 39 #include "tmVector.h" 40 #ifdef VBOX_USE_IPRT_IN_XPCOM 41 # include <iprt/mem.h> 42 #endif 40 41 #include <iprt/mem.h> 43 42 44 43 //////////////////////////////////////////////////////////////////////////// … … 49 48 tmVector::~tmVector() { 50 49 if (mElements) 51 #ifdef VBOX_USE_IPRT_IN_XPCOM52 50 RTMemFree((void*)mElements); 53 #else54 free((void*)mElements);55 #endif56 51 } 57 52 … … 62 57 tmVector::Init() { 63 58 64 #ifdef VBOX_USE_IPRT_IN_XPCOM65 59 mElements = (void**) RTMemAllocZ (mCapacity * sizeof(void*)); 66 #else67 mElements = (void**) calloc (mCapacity, sizeof(void*));68 #endif69 60 if (!mElements) 70 61 return NS_ERROR_OUT_OF_MEMORY; … … 77 68 PRInt32 78 69 tmVector::Append(void *aElement){ 79 PR_ASSERT(aElement);70 Assert(aElement); 80 71 81 72 // make sure there is room … … 94 85 void 95 86 tmVector::Remove(void *aElement) { 96 PR_ASSERT(aElement);87 Assert(aElement); 97 88 98 89 for (PRUint32 index = 0; index < mNext; index++) { … … 111 102 void 112 103 tmVector::RemoveAt(PRUint32 aIndex) { 113 PR_ASSERT(aIndex < mNext);104 Assert(aIndex < mNext); 114 105 115 106 // remove the element if it isn't already nsnull … … 148 139 149 140 PRUint32 newcap = mCapacity + GROWTH_INC; 150 #ifdef VBOX_USE_IPRT_IN_XPCOM151 141 mElements = (void**) RTMemRealloc(mElements, (newcap * sizeof(void*))); 152 #else153 mElements = (void**) realloc(mElements, (newcap * sizeof(void*)));154 #endif155 142 if (mElements) { 156 143 mCapacity = newcap; … … 167 154 PRUint32 newcap = mCapacity - GROWTH_INC; 168 155 if (mNext < newcap) { 169 #ifdef VBOX_USE_IPRT_IN_XPCOM170 156 mElements = (void**) RTMemRealloc(mElements, newcap * sizeof(void*)); 171 #else172 mElements = (void**) realloc(mElements, newcap * sizeof(void*));173 #endif174 157 if (!mElements) 175 158 return NS_ERROR_OUT_OF_MEMORY;
Note:
See TracChangeset
for help on using the changeset viewer.