Add LeakChecked qualifiers to key classes

This commit is contained in:
Vinnie Falco
2013-06-30 03:49:41 -07:00
parent c46b35732a
commit 68179cfce3
38 changed files with 93 additions and 67 deletions

View File

@@ -2,6 +2,8 @@
RIPPLE TODO RIPPLE TODO
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
- Merge ripple_Version.h and ripple_BuildVersion.h
- Restructure the ripple sources to have this directory structure: - Restructure the ripple sources to have this directory structure:
/Source/ripple/ripple_core/ripple_core.h /Source/ripple/ripple_core/ripple_core.h
etc... etc...

View File

@@ -4,8 +4,8 @@
*/ */
//============================================================================== //==============================================================================
#ifndef RIPPLE_KEYCACHE_H #ifndef RIPPLE_KEYCACHE_H_INCLUDED
#define RIPPLE_KEYCACHE_H #define RIPPLE_KEYCACHE_H_INCLUDED
/** Maintains a cache of keys with no associated data. /** Maintains a cache of keys with no associated data.
@@ -36,7 +36,10 @@ public:
*/ */
KeyCache (const std::string& name, KeyCache (const std::string& name,
int size = 0, int size = 0,
int age = 120) : mName (name), mTargetSize (size), mTargetAge (age) int age = 120)
: mName (name)
, mTargetSize (size)
, mTargetAge (age)
{ {
assert ((size >= 0) && (age > 2)); assert ((size >= 0) && (age > 2));
} }
@@ -80,7 +83,7 @@ public:
/** Retrieve the name of this object. /** Retrieve the name of this object.
*/ */
const std::string& getName () std::string const& getName ()
{ {
return mName; return mName;
} }

View File

@@ -34,7 +34,7 @@ uint32 RangeSet::getFirst () const
const_iterator it = mRanges.begin (); const_iterator it = mRanges.begin ();
if (it == mRanges.end ()) if (it == mRanges.end ())
return RangeSetAbsent; return absent;
return it->first; return it->first;
} }
@@ -49,7 +49,7 @@ uint32 RangeSet::getNext (uint32 v) const
if (contains (it, v + 1)) if (contains (it, v + 1))
return v + 1; return v + 1;
} }
return RangeSetAbsent; return absent;
} }
uint32 RangeSet::getLast () const uint32 RangeSet::getLast () const
@@ -57,7 +57,7 @@ uint32 RangeSet::getLast () const
const_reverse_iterator it = mRanges.rbegin (); const_reverse_iterator it = mRanges.rbegin ();
if (it == mRanges.rend ()) if (it == mRanges.rend ())
return RangeSetAbsent; return absent;
return it->second; return it->second;
} }
@@ -72,7 +72,7 @@ uint32 RangeSet::getPrev (uint32 v) const
if (contains (it, v + 1)) if (contains (it, v + 1))
return v - 1; return v - 1;
} }
return RangeSetAbsent; return absent;
} }
uint32 RangeSet::prevMissing (uint32 v) const uint32 RangeSet::prevMissing (uint32 v) const
@@ -86,7 +86,7 @@ uint32 RangeSet::prevMissing (uint32 v) const
if (it.first > (v + 1)) if (it.first > (v + 1))
return v + 1; return v + 1;
} }
return RangeSetAbsent; return absent;
} }
void RangeSet::setValue (uint32 v) void RangeSet::setValue (uint32 v)

View File

@@ -4,8 +4,8 @@
*/ */
//============================================================================== //==============================================================================
#ifndef RIPPLE_RANGESET_H #ifndef RIPPLE_RANGESET_H_INCLUDED
#define RIPPLE_RANGESET_H #define RIPPLE_RANGESET_H_INCLUDED
/** A sparse set of integers. /** A sparse set of integers.
*/ */
@@ -13,39 +13,45 @@
class RangeSet class RangeSet
{ {
public: public:
static const uint32 RangeSetAbsent = static_cast<uint32> (-1); static const uint32 absent = static_cast <uint32> (-1);
protected:
std::map<uint32, uint32> mRanges; // First is lowest value in range, last is highest value in range
typedef std::map<uint32, uint32>::const_iterator const_iterator;
typedef std::map<uint32, uint32>::const_reverse_iterator const_reverse_iterator;
typedef std::map<uint32, uint32>::value_type value_type;
typedef std::map<uint32, uint32>::iterator iterator;
static bool contains (value_type const& it, uint32 v)
{
return (it.first <= v) && (it.second >= v);
}
void simplify ();
public: public:
RangeSet () { } RangeSet () { }
bool hasValue (uint32) const; bool hasValue (uint32) const;
uint32 getFirst () const; uint32 getFirst () const;
uint32 getNext (uint32) const; uint32 getNext (uint32) const;
uint32 getLast () const; uint32 getLast () const;
uint32 getPrev (uint32) const; uint32 getPrev (uint32) const;
uint32 prevMissing (uint32) const; // largest number not in the set that is less than the given number // largest number not in the set that is less than the given number
uint32 prevMissing (uint32) const;
void setValue (uint32); void setValue (uint32);
void setRange (uint32, uint32); void setRange (uint32, uint32);
void clearValue (uint32); void clearValue (uint32);
std::string toString () const; std::string toString () const;
private:
void simplify ();
private:
typedef std::map <uint32, uint32> Map;
typedef Map::const_iterator const_iterator;
typedef Map::const_reverse_iterator const_reverse_iterator;
typedef Map::value_type value_type;
typedef Map::iterator iterator;
static bool contains (value_type const& it, uint32 v)
{
return (it.first <= v) && (it.second >= v);
}
// First is lowest value in range, last is highest value in range
Map mRanges;
}; };
#endif #endif

View File

@@ -4,8 +4,8 @@
*/ */
//============================================================================== //==============================================================================
#ifndef RIPPLE_SECUREALLOCATOR_H #ifndef RIPPLE_SECUREALLOCATOR_H_INCLUDED
#define RIPPLE_SECUREALLOCATOR_H #define RIPPLE_SECUREALLOCATOR_H_INCLUDED
// //
// Allocator that locks its contents from being paged // Allocator that locks its contents from being paged

View File

@@ -14,8 +14,7 @@
done by seeding the hashing function with a random number generated done by seeding the hashing function with a random number generated
at program startup. at program startup.
*/ */
// VFALCO TODO derive from Uncopyable class HashMaps : Uncopyable
class HashMaps // : beast::Uncopayble
{ {
public: public:
/** Golden ratio constant used in hashing functions. /** Golden ratio constant used in hashing functions.

View File

@@ -83,7 +83,7 @@ private:
@ingroup ripple_basics @ingroup ripple_basics
*/ */
template <class Object> template <class Object>
class CountedObject class CountedObject : LeakChecked <CountedObject <Object> >
{ {
public: public:
CountedObject () CountedObject ()

View File

@@ -11,7 +11,9 @@
// Async https client. // Async https client.
// //
class HttpsClient : public boost::enable_shared_from_this<HttpsClient> class HttpsClient
: public boost::enable_shared_from_this <HttpsClient>
, LeakChecked <HttpsClient>
{ {
public: public:
HttpsClient ( HttpsClient (

View File

@@ -179,7 +179,7 @@ bool LedgerMaster::haveLedgerRange (uint32 from, uint32 to)
{ {
boost::recursive_mutex::scoped_lock sl (mLock); boost::recursive_mutex::scoped_lock sl (mLock);
uint32 prevMissing = mCompleteLedgers.prevMissing (to + 1); uint32 prevMissing = mCompleteLedgers.prevMissing (to + 1);
return (prevMissing == RangeSet::RangeSetAbsent) || (prevMissing < from); return (prevMissing == RangeSet::absent) || (prevMissing < from);
} }
bool LedgerMaster::haveLedger (uint32 seq) bool LedgerMaster::haveLedger (uint32 seq)
@@ -202,7 +202,7 @@ bool LedgerMaster::getValidatedRange (uint32& minVal, uint32& maxVal)
minVal = mCompleteLedgers.prevMissing (maxVal); minVal = mCompleteLedgers.prevMissing (maxVal);
if (minVal == RangeSet::RangeSetAbsent) if (minVal == RangeSet::absent)
minVal = 0; minVal = 0;
else else
++minVal; ++minVal;
@@ -440,7 +440,7 @@ void LedgerMaster::resumeAcquiring ()
uint32 prevMissing = mCompleteLedgers.prevMissing (mFinalizedLedger->getLedgerSeq ()); uint32 prevMissing = mCompleteLedgers.prevMissing (mFinalizedLedger->getLedgerSeq ());
if (prevMissing == RangeSet::RangeSetAbsent) if (prevMissing == RangeSet::absent)
{ {
WriteLog (lsDEBUG, LedgerMaster) << "no prior missing ledger, not resuming"; WriteLog (lsDEBUG, LedgerMaster) << "no prior missing ledger, not resuming";
return; return;
@@ -564,7 +564,7 @@ void LedgerMaster::setFullLedger (Ledger::pointer ledger)
{ {
uint32 prevMissing = mCompleteLedgers.prevMissing (ledger->getLedgerSeq ()); uint32 prevMissing = mCompleteLedgers.prevMissing (ledger->getLedgerSeq ());
if (prevMissing == RangeSet::RangeSetAbsent) if (prevMissing == RangeSet::absent)
{ {
WriteLog (lsDEBUG, LedgerMaster) << "no prior missing ledger"; WriteLog (lsDEBUG, LedgerMaster) << "no prior missing ledger";
return; return;

View File

@@ -14,7 +14,7 @@
// VFALCO TODO Rename to Ledgers // VFALCO TODO Rename to Ledgers
// It sounds like this holds all the ledgers... // It sounds like this holds all the ledgers...
// //
class LedgerMaster class LedgerMaster : LeakChecked <LedgerMaster>
{ {
public: public:
typedef FUNCTION_TYPE <void (Ledger::ref)> callback; typedef FUNCTION_TYPE <void (Ledger::ref)> callback;

View File

@@ -13,7 +13,7 @@
class Peer; class Peer;
class LedgerConsensus; class LedgerConsensus;
class NetworkOPs class NetworkOPs : LeakChecked <NetworkOPs>
{ {
public: public:
enum Fault enum Fault

View File

@@ -34,7 +34,7 @@ private:
boost::recursive_mutex mLock; boost::recursive_mutex mLock;
}; };
class OrderBookDB class OrderBookDB : LeakChecked <OrderBookDB>
{ {
public: public:
OrderBookDB (); OrderBookDB ();

View File

@@ -11,7 +11,7 @@
Handles incoming connections from other Peers Handles incoming connections from other Peers
*/ */
class PeerDoor class PeerDoor : LeakChecked <PeerDoor>
{ {
public: public:
PeerDoor (boost::asio::io_service& io_service); PeerDoor (boost::asio::io_service& io_service);

View File

@@ -11,7 +11,7 @@
Handles incoming connections from people making RPC Requests Handles incoming connections from people making RPC Requests
*/ */
class RPCDoor class RPCDoor : LeakChecked <RPCDoor>
{ {
public: public:
explicit RPCDoor (boost::asio::io_service& io_service); explicit RPCDoor (boost::asio::io_service& io_service);

View File

@@ -7,7 +7,9 @@
#ifndef __RPCSERVER__ #ifndef __RPCSERVER__
#define __RPCSERVER__ #define __RPCSERVER__
class RPCServer : public boost::enable_shared_from_this<RPCServer> class RPCServer
: public boost::enable_shared_from_this<RPCServer>
, LeakChecked <RPCServer>
{ {
public: public:

View File

@@ -10,7 +10,9 @@
#define RPC_EVENT_QUEUE_MAX 32 #define RPC_EVENT_QUEUE_MAX 32
// Subscription object for JSON-RPC // Subscription object for JSON-RPC
class RPCSub : public InfoSub class RPCSub
: public InfoSub
, LeakChecked <RPCSub>
{ {
public: public:
typedef boost::shared_ptr<RPCSub> pointer; typedef boost::shared_ptr<RPCSub> pointer;

View File

@@ -20,7 +20,7 @@ public:
} }
}; };
class SNTPClient class SNTPClient : LeakChecked <SNTPClient>
{ {
public: public:
SNTPClient (boost::asio::io_service& service); SNTPClient (boost::asio::io_service& service);

View File

@@ -9,7 +9,7 @@
// Tracks all transactions in memory // Tracks all transactions in memory
class TransactionMaster class TransactionMaster : LeakChecked <TransactionMaster>
{ {
public: public:
TransactionMaster (); TransactionMaster ();

View File

@@ -7,7 +7,7 @@
#ifndef RIPPLE_TRANSACTIONMETA_H #ifndef RIPPLE_TRANSACTIONMETA_H
#define RIPPLE_TRANSACTIONMETA_H #define RIPPLE_TRANSACTIONMETA_H
class TransactionMetaSet class TransactionMetaSet : LeakChecked <TransactionMetaSet>
{ {
public: public:
typedef boost::shared_ptr<TransactionMetaSet> pointer; typedef boost::shared_ptr<TransactionMetaSet> pointer;

View File

@@ -53,7 +53,7 @@ private:
void addCallbacks (const TXQEntry& otherEntry); void addCallbacks (const TXQEntry& otherEntry);
}; };
class TXQueue class TXQueue : LeakChecked <TXQueue>
{ {
public: public:
TXQueue () : mRunning (false) TXQueue () : mRunning (false)

View File

@@ -7,7 +7,7 @@
#ifndef RIPPLE_WSDOOR_RIPPLEHEADER #ifndef RIPPLE_WSDOOR_RIPPLEHEADER
#define RIPPLE_WSDOOR_RIPPLEHEADER #define RIPPLE_WSDOOR_RIPPLEHEADER
class WSDoor class WSDoor : LeakChecked <WSDoor>
{ {
private: private:
websocketpp::server_autotls* mSEndpoint; websocketpp::server_autotls* mSEndpoint;

View File

@@ -23,7 +23,9 @@ struct WSServerHandlerLog;
// This instance dispatches all events. There is no per connection persistence. // This instance dispatches all events. There is no per connection persistence.
template <typename endpoint_type> template <typename endpoint_type>
class WSServerHandler : public endpoint_type::handler class WSServerHandler
: public endpoint_type::handler
, LeakChecked <WSServerHandler <endpoint_type> >
{ {
public: public:
typedef typename endpoint_type::handler::connection_ptr connection_ptr; typedef typename endpoint_type::handler::connection_ptr connection_ptr;

View File

@@ -9,7 +9,7 @@
/** A set of AccountItem objects. /** A set of AccountItem objects.
*/ */
class AccountItems class AccountItems : LeakChecked <AccountItems>
{ {
public: public:
typedef boost::shared_ptr <AccountItems> pointer; typedef boost::shared_ptr <AccountItems> pointer;

View File

@@ -11,7 +11,7 @@
// Provide abstract access to an account's state, such that access to the serialized format is hidden. // Provide abstract access to an account's state, such that access to the serialized format is hidden.
// //
class AccountState class AccountState : LeakChecked <AccountState>
{ {
public: public:
typedef boost::shared_ptr<AccountState> pointer; typedef boost::shared_ptr<AccountState> pointer;

View File

@@ -15,7 +15,7 @@
*/ */
// VFALCO TODO rename to SortedTxSet // VFALCO TODO rename to SortedTxSet
class CanonicalTXSet class CanonicalTXSet : LeakChecked <CanonicalTXSet>
{ {
public: public:
class Key class Key

View File

@@ -10,7 +10,7 @@
/** Persistency layer for hashed objects. /** Persistency layer for hashed objects.
*/ */
// VFALCO TODO Move all definitions to the .cpp // VFALCO TODO Move all definitions to the .cpp
class HashedObjectStore class HashedObjectStore : LeakChecked <HashedObjectStore>
{ {
public: public:
HashedObjectStore (int cacheSize, int cacheAge); HashedObjectStore (int cacheSize, int cacheAge);

View File

@@ -20,7 +20,7 @@ enum POWResult
// VFALCO TODO move this to the class as a static member and rename it // VFALCO TODO move this to the class as a static member and rename it
bool powResultInfo (POWResult powCode, std::string& strToken, std::string& strHuman); bool powResultInfo (POWResult powCode, std::string& strToken, std::string& strHuman);
class IProofOfWorkFactory class IProofOfWorkFactory : LeakChecked <IProofOfWorkFactory>
{ {
public: public:
typedef boost::bimap< boost::bimaps::multiset_of<time_t>, boost::bimaps::unordered_set_of<uint256> > powMap_t; typedef boost::bimap< boost::bimaps::multiset_of<time_t>, boost::bimaps::unordered_set_of<uint256> > powMap_t;

View File

@@ -11,7 +11,7 @@
typedef boost::unordered_map<uint160, SerializedValidation::pointer> ValidationSet; typedef boost::unordered_map<uint160, SerializedValidation::pointer> ValidationSet;
typedef std::pair<int, uint160> currentValidationCount; // nodes validating and highest node ID validating typedef std::pair<int, uint160> currentValidationCount; // nodes validating and highest node ID validating
class IValidations class IValidations : LeakChecked <IValidations>
{ {
public: public:
static IValidations* New (); static IValidations* New ();

View File

@@ -13,7 +13,7 @@
*/ */
// VFALCO TODO Rename to InboundLedgers // VFALCO TODO Rename to InboundLedgers
// VFALCO TODO Create abstract interface // VFALCO TODO Create abstract interface
class InboundLedgers class InboundLedgers : LeakChecked <InboundLedger>
{ {
public: public:
// How long before we try again to acquire the same ledger // How long before we try again to acquire the same ledger

View File

@@ -8,7 +8,7 @@
#define RIPPLE_LEDGERHISTORY_H #define RIPPLE_LEDGERHISTORY_H
// VFALCO TODO Rename to OldLedgers ? // VFALCO TODO Rename to OldLedgers ?
class LedgerHistory class LedgerHistory : LeakChecked <LedgerHistory>
{ {
public: public:
LedgerHistory (); LedgerHistory ();

View File

@@ -9,7 +9,7 @@
/** Holds the cryptographic credentials identifying this instance of the server. /** Holds the cryptographic credentials identifying this instance of the server.
*/ */
class LocalCredentials // derive from Uncopyable class LocalCredentials : Uncopyable
{ {
public: public:
LocalCredentials (); LocalCredentials ();

View File

@@ -10,7 +10,7 @@
/** Describes a serialized ledger entry for an order book. /** Describes a serialized ledger entry for an order book.
*/ */
class OrderBook class OrderBook : LeakChecked <OrderBook>
{ {
public: public:
typedef boost::shared_ptr <OrderBook> pointer; typedef boost::shared_ptr <OrderBook> pointer;

View File

@@ -10,7 +10,9 @@
// VFALCO TODO Couldn't this be a struct? // VFALCO TODO Couldn't this be a struct?
typedef std::pair <std::string, int> ipPort; typedef std::pair <std::string, int> ipPort;
class Peer : public boost::enable_shared_from_this <Peer> class Peer
: public boost::enable_shared_from_this <Peer>
, LeakChecked <Peer>
{ {
public: public:
typedef boost::shared_ptr<Peer> pointer; typedef boost::shared_ptr<Peer> pointer;

View File

@@ -11,7 +11,7 @@
A peer set is used to acquire a ledger or a transaction set. A peer set is used to acquire a ledger or a transaction set.
*/ */
class PeerSet class PeerSet : LeakChecked <PeerSet>
{ {
public: public:
uint256 const& getHash () const uint256 const& getHash () const

View File

@@ -14,7 +14,9 @@ class Peers;
SETUP_LOG (Peers) SETUP_LOG (Peers)
class Peers : public IPeers class Peers
: public IPeers
, LeakChecked <Peers>
{ {
public: public:
explicit Peers (boost::asio::io_service& io_service) explicit Peers (boost::asio::io_service& io_service)

View File

@@ -7,7 +7,7 @@
#ifndef RIPPLE_PROOFOFWORK_H #ifndef RIPPLE_PROOFOFWORK_H
#define RIPPLE_PROOFOFWORK_H #define RIPPLE_PROOFOFWORK_H
class ProofOfWork class ProofOfWork : LeakChecked <ProofOfWork>
{ {
public: public:
static const int sMaxDifficulty; static const int sMaxDifficulty;

View File

@@ -9,7 +9,9 @@
// PRIVATE HEADER // PRIVATE HEADER
class ProofOfWorkFactory : public IProofOfWorkFactory class ProofOfWorkFactory
: public IProofOfWorkFactory
, LeakChecked <ProofOfWorkFactory>
{ {
public: public:
ProofOfWorkFactory (); ProofOfWorkFactory ();

View File

@@ -6,10 +6,12 @@
#ifndef RIPPLE_VERSION_H #ifndef RIPPLE_VERSION_H
#define RIPPLE_VERSION_H #define RIPPLE_VERSION_H
// //
// Versions // Versions
// //
// VFALCO TODO Roll this together into ripple_BuildVersion
#define SERVER_VERSION_MAJOR 0 #define SERVER_VERSION_MAJOR 0
#define SERVER_VERSION_MINOR 9 #define SERVER_VERSION_MINOR 9
#define SERVER_VERSION_SUB "-b" #define SERVER_VERSION_SUB "-b"