Changeset 20232

Show
Ignore:
Timestamp:
05/21/07 14:25:59 (2 years ago)
Author:
aronb
Message:

Fix a few memory leaks when dealing with file handles and IO strategies.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • juggler/trunk/modules/vapor/vpr/IO/BlockIO.cpp

    r19846 r20232  
    122122BlockIO::~BlockIO() 
    123123{ 
    124    /* Do nothing. */ ; 
     124   if (NULL != mStatsStrategy) 
     125   { 
     126      delete mStatsStrategy; 
     127   } 
    125128} 
    126129 
  • juggler/trunk/modules/vapor/vpr/IO/BlockIO.h

    r19846 r20232  
    500500   void setIOStatStrategy(vpr::BaseIOStatsStrategy* strat) 
    501501   { 
     502      if (NULL != mStatsStrategy) 
     503      { 
     504         delete mStatsStrategy; 
     505      } 
    502506      mStatsStrategy = strat; 
    503507      if(mStatsStrategy != NULL)              // If we have a non-NULL strategy 
  • juggler/trunk/modules/vapor/vpr/md/POSIX/IO/Socket/SocketStreamImplBSD.cpp

    r19729 r20232  
    7272   : SocketImplBSD(sock.mLocalAddr, sock.mRemoteAddr, SocketTypes::STREAM) 
    7373{ 
     74   // mHandle is created in the base class constructor. Since we are creating 
     75   // a copy we must clean up existing memory. 
     76   if (NULL != mHandle) 
     77   { 
     78      delete mHandle; 
     79      mHandle = NULL; 
     80   } 
     81 
    7482   mHandle         = new FileHandleImplUNIX(sock.mHandle->getName()); 
    7583   mHandle->mFdesc = sock.mHandle->mFdesc; 
     
    135143   { 
    136144      sock.setRemoteAddr(addr); 
     145 
     146      // Clean up the existing handle. 
     147      if (NULL != sock.mHandle) 
     148      { 
     149         delete sock.mHandle; 
     150         sock.mHandle = NULL; 
     151      } 
    137152      sock.mHandle         = new FileHandleImplUNIX(addr.getAddressString()); 
    138153      sock.mHandle->mFdesc = accept_sock;