VirtualBox

Ignore:
Timestamp:
Jul 30, 2010 8:02:05 PM (14 years ago)
Author:
vboxsync
Message:

xpcom: Use RTMem* for memory alloc so that we can more easily wrap direct it to the electric fence heap.

Location:
trunk/src/libs/xpcom18a4/ipc/ipcd/extensions/transmngr/common
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/ipc/ipcd/extensions/transmngr/common/tmTransaction.cpp

    r1 r31259  
    3838#include <stdlib.h>
    3939#include "tmTransaction.h"
     40#ifdef VBOX_USE_IPRT_IN_XPCOM
     41# include <iprt/mem.h>
     42#endif
    4043
    4144///////////////////////////////////////////////////////////////////////////////
     
    4447tmTransaction::~tmTransaction() {
    4548  if (mHeader)
     49#ifdef VBOX_USE_IPRT_IN_XPCOM
     50    RTMemFree(mHeader);
     51#else
    4652    free(mHeader);
     53#endif
    4754}
    4855
     
    5158nsresult
    5259tmTransaction::Init(PRUint32 aOwnerID,
    53                     PRInt32  aQueueID, 
    54                     PRUint32 aAction, 
    55                     PRInt32  aStatus, 
    56                     const PRUint8 *aMessage, 
     60                    PRInt32  aQueueID,
     61                    PRUint32 aAction,
     62                    PRInt32  aStatus,
     63                    const PRUint8 *aMessage,
    5764                    PRUint32 aLength) {
    5865  nsresult rv = NS_OK;
     
    6168  // indicates the message is the entire raw message
    6269  if (aQueueID == TM_INVALID_ID) {
     70#ifdef VBOX_USE_IPRT_IN_XPCOM
     71    header = (tmHeader*) RTMemAlloc(aLength);
     72#else
    6373    header = (tmHeader*) malloc(aLength);
     74#endif
    6475    if (header) {
    6576      mRawMessageLength = aLength;
     
    7081  }
    7182  else {   // need to create the tmHeader and concat the message
     83#ifdef VBOX_USE_IPRT_IN_XPCOM
     84    header = (tmHeader*) RTMemAlloc (sizeof(tmHeader) + aLength);
     85#else
    7286    header = (tmHeader*) malloc (sizeof(tmHeader) + aLength);
     87#endif
    7388    if (header) {
    7489      mRawMessageLength = sizeof(tmHeader) + aLength;
  • trunk/src/libs/xpcom18a4/ipc/ipcd/extensions/transmngr/common/tmVector.cpp

    r1 r31259  
    3838#include <stdlib.h>
    3939#include "tmVector.h"
     40#ifdef VBOX_USE_IPRT_IN_XPCOM
     41# include <iprt/mem.h>
     42#endif
    4043
    4144////////////////////////////////////////////////////////////////////////////
     
    4649tmVector::~tmVector() {
    4750  if (mElements)
     51#ifdef VBOX_USE_IPRT_IN_XPCOM
     52    RTMemFree((void*)mElements);
     53#else
    4854    free((void*)mElements);
     55#endif
    4956}
    5057
     
    5562tmVector::Init() {
    5663
     64#ifdef VBOX_USE_IPRT_IN_XPCOM
     65  mElements = (void**) RTMemAllocZ (mCapacity * sizeof(void*));
     66#else
    5767  mElements = (void**) calloc (mCapacity, sizeof(void*));
     68#endif
    5869  if (!mElements)
    5970    return NS_ERROR_OUT_OF_MEMORY;
     
    117128//tmVector::operator[](int index) {
    118129//  if (index < mNext && index >= 0)
    119 //    return mElements[index]; 
     130//    return mElements[index];
    120131//  return nsnull;
    121132//}
     
    137148
    138149  PRUint32 newcap = mCapacity + GROWTH_INC;
     150#ifdef VBOX_USE_IPRT_IN_XPCOM
     151  mElements = (void**) RTMemRealloc(mElements, (newcap * sizeof(void*)));
     152#else
    139153  mElements = (void**) realloc(mElements, (newcap * sizeof(void*)));
     154#endif
    140155  if (mElements) {
    141156    mCapacity = newcap;
     
    152167  PRUint32 newcap = mCapacity - GROWTH_INC;
    153168  if (mNext < newcap) {
     169#ifdef VBOX_USE_IPRT_IN_XPCOM
     170    mElements = (void**) RTMemRealloc(mElements, newcap * sizeof(void*));
     171#else
    154172    mElements = (void**) realloc(mElements, newcap * sizeof(void*));
     173#endif
    155174    if (!mElements)
    156175      return NS_ERROR_OUT_OF_MEMORY;
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