Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

some small fixes for main.cpp/.h #2005

Merged
merged 1 commit into from

3 participants

@Diapolo
  • remove an unwanted ";" at the end of the ~CCoinsView() destructor
  • in FindBlockPos() and FindUndoPos() only call fclose(), if file is open
  • fix an error string in the CBlockUndo class
@Diapolo Diapolo some small fixes for main.cpp/.h
- remove an unwanted ";" at the end of the ~CCoinsView() destructor
- in FindBlockPos() and FindUndoPos() only call fclose(), is file is open
- fix an error string in the CBlockUndo class
13e5cce
@laanwj
Owner

Indeed:

   The behaviour of fclose() is undefined if the stream parameter is an illegal pointer, or is a descriptor already passed to a previous invoca‐
   tion of fclose().

ACK

@jgarzik jgarzik merged commit 824e196 into bitcoin:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 11, 2012
  1. @Diapolo

    some small fixes for main.cpp/.h

    Diapolo authored
    - remove an unwanted ";" at the end of the ~CCoinsView() destructor
    - in FindBlockPos() and FindUndoPos() only call fclose(), is file is open
    - fix an error string in the CBlockUndo class
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 8 deletions.
  1. +4 −4 src/main.cpp
  2. +2 −4 src/main.h
View
8 src/main.cpp
@@ -719,7 +719,7 @@ bool CTxMemPool::accept(CTransaction &tx, bool fCheckInputs,
// are the actual inputs available?
if (!tx.HaveInputs(view))
return error("CTxMemPool::accept() : inputs already spent");
-
+
// Bring the best block into scope
view.GetBestBlock();
@@ -1338,7 +1338,7 @@ bool CTransaction::CheckInputs(CCoinsViewCache &inputs, enum CheckSig_mode csmod
// While checking, GetBestBlock() refers to the parent block.
// This is also true for mempool checks.
- int nSpendHeight = inputs.GetBestBlock()->nHeight + 1;
+ int nSpendHeight = inputs.GetBestBlock()->nHeight + 1;
int64 nValueIn = 0;
int64 nFees = 0;
for (unsigned int i = 0; i < vin.size(); i++)
@@ -1899,8 +1899,8 @@ bool FindBlockPos(CDiskBlockPos &pos, unsigned int nAddSize, unsigned int nHeigh
if (file) {
printf("Pre-allocating up to position 0x%x in blk%05u.dat\n", nNewChunks * BLOCKFILE_CHUNK_SIZE, pos.nFile);
AllocateFileRange(file, pos.nPos, nNewChunks * BLOCKFILE_CHUNK_SIZE - pos.nPos);
+ fclose(file);
}
- fclose(file);
}
}
@@ -1941,8 +1941,8 @@ bool FindUndoPos(int nFile, CDiskBlockPos &pos, unsigned int nAddSize)
if (file) {
printf("Pre-allocating up to position 0x%x in rev%05u.dat\n", nNewChunks * UNDOFILE_CHUNK_SIZE, pos.nFile);
AllocateFileRange(file, pos.nPos, nNewChunks * UNDOFILE_CHUNK_SIZE - pos.nPos);
+ fclose(file);
}
- fclose(file);
}
return true;
View
6 src/main.h
@@ -733,7 +733,6 @@ class CBlockUndo
bool WriteToDisk(CDiskBlockPos &pos)
{
-
// Open history file to append
CAutoFile fileout = CAutoFile(OpenUndoFile(pos), SER_DISK, CLIENT_VERSION);
if (!fileout)
@@ -746,7 +745,7 @@ class CBlockUndo
// Write undo data
long fileOutPos = ftell(fileout);
if (fileOutPos < 0)
- return error("CBlock::WriteToDisk() : ftell failed");
+ return error("CBlockUndo::WriteToDisk() : ftell failed");
pos.nPos = (unsigned int)fileOutPos;
fileout << *this;
@@ -757,7 +756,6 @@ class CBlockUndo
return true;
}
-
};
/** pruned version of CTransaction: only retains metadata and unspent transaction outputs
@@ -1872,7 +1870,7 @@ class CCoinsView
virtual bool GetStats(CCoinsStats &stats);
// As we use CCoinsViews polymorphically, have a virtual destructor
- virtual ~CCoinsView() {};
+ virtual ~CCoinsView() {}
};
/** CCoinsView backed by another CCoinsView */
Something went wrong with that request. Please try again.