aboutsummaryrefslogtreecommitdiff
path: root/src/db.cpp
diff options
context:
space:
mode:
authorPhilip Kaufmann <phil.kaufmann@t-online.de>2014-09-16 15:16:29 +0200
committerPhilip Kaufmann <phil.kaufmann@t-online.de>2014-09-18 07:21:49 +0200
commit22d7e7014f2064fb9e52c634f68b3c5e965faec0 (patch)
treee958045998cf5cb60b30a3915e4b08f84731e9a9 /src/db.cpp
parent438c7e4cd2179170aeadb4aa1c902ccd1256dee6 (diff)
prefer const string& over char* in CDB and CWalletDB constructor
- also make parameter of CDBEnv::CheckpointLSN a constant reference
Diffstat (limited to 'src/db.cpp')
-rw-r--r--src/db.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/db.cpp b/src/db.cpp
index edbff6fd49..24206d34e1 100644
--- a/src/db.cpp
+++ b/src/db.cpp
@@ -215,7 +215,7 @@ bool CDBEnv::Salvage(std::string strFile, bool fAggressive,
}
-void CDBEnv::CheckpointLSN(std::string strFile)
+void CDBEnv::CheckpointLSN(const std::string& strFile)
{
dbenv.txn_checkpoint(0, 0, 0);
if (fMockDb)
@@ -224,12 +224,12 @@ void CDBEnv::CheckpointLSN(std::string strFile)
}
-CDB::CDB(const char *pszFile, const char* pszMode) :
+CDB::CDB(const std::string& strFilename, const char* pszMode) :
pdb(NULL), activeTxn(NULL)
{
int ret;
fReadOnly = (!strchr(pszMode, '+') && !strchr(pszMode, 'w'));
- if (pszFile == NULL)
+ if (strFilename.empty())
return;
bool fCreate = strchr(pszMode, 'c') != NULL;
@@ -242,7 +242,7 @@ CDB::CDB(const char *pszFile, const char* pszMode) :
if (!bitdb.Open(GetDataDir()))
throw runtime_error("CDB : Failed to open database environment.");
- strFile = pszFile;
+ strFile = strFilename;
++bitdb.mapFileUseCount[strFile];
pdb = bitdb.mapDb[strFile];
if (pdb == NULL)
@@ -255,14 +255,14 @@ CDB::CDB(const char *pszFile, const char* pszMode) :
DbMpoolFile*mpf = pdb->get_mpf();
ret = mpf->set_flags(DB_MPOOL_NOFILE, 1);
if (ret != 0)
- throw runtime_error(strprintf("CDB : Failed to configure for no temp file backing for database %s", pszFile));
+ throw runtime_error(strprintf("CDB : Failed to configure for no temp file backing for database %s", strFile));
}
- ret = pdb->open(NULL, // Txn pointer
- fMockDb ? NULL : pszFile, // Filename
- fMockDb ? pszFile : "main", // Logical db name
- DB_BTREE, // Database type
- nFlags, // Flags
+ ret = pdb->open(NULL, // Txn pointer
+ fMockDb ? NULL : strFile.c_str(), // Filename
+ fMockDb ? strFile.c_str() : "main", // Logical db name
+ DB_BTREE, // Database type
+ nFlags, // Flags
0);
if (ret != 0)
@@ -271,7 +271,7 @@ CDB::CDB(const char *pszFile, const char* pszMode) :
pdb = NULL;
--bitdb.mapFileUseCount[strFile];
strFile = "";
- throw runtime_error(strprintf("CDB : Error %d, can't open database %s", ret, pszFile));
+ throw runtime_error(strprintf("CDB : Error %d, can't open database %s", ret, strFile));
}
if (fCreate && !Exists(string("version")))