free CBlockIndex if it is allocated.
This commit is contained in:
parent
58e92d13e7
commit
53e1044d8b
@ -2781,7 +2781,7 @@ async_import_key_after(uv_work_t *req) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
CBlockIndex *
|
CBlockIndex *
|
||||||
find_new_block_index(uint256 hash, uint256 hashPrevBlock) {
|
find_new_block_index(uint256 hash, uint256 hashPrevBlock, bool *is_allocated) {
|
||||||
// Check for duplicate
|
// Check for duplicate
|
||||||
BlockMap::iterator it = mapBlockIndex.find(hash);
|
BlockMap::iterator it = mapBlockIndex.find(hash);
|
||||||
if (it != mapBlockIndex.end()) {
|
if (it != mapBlockIndex.end()) {
|
||||||
@ -2797,13 +2797,16 @@ find_new_block_index(uint256 hash, uint256 hashPrevBlock) {
|
|||||||
pindexNew->nHeight = pindexNew->pprev->nHeight + 1;
|
pindexNew->nHeight = pindexNew->pprev->nHeight + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*is_allocated = true;
|
||||||
|
|
||||||
return pindexNew;
|
return pindexNew;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
cblock_to_jsblock(const CBlock& cblock, CBlockIndex* cblock_index, Local<Object> jsblock, bool isNew) {
|
cblock_to_jsblock(const CBlock& cblock, CBlockIndex* cblock_index, Local<Object> jsblock, bool isNew) {
|
||||||
|
bool is_allocated = false;
|
||||||
if (!cblock_index && isNew) {
|
if (!cblock_index && isNew) {
|
||||||
cblock_index = find_new_block_index(cblock.GetHash(), cblock.hashPrevBlock);
|
cblock_index = find_new_block_index(cblock.GetHash(), cblock.hashPrevBlock, &is_allocated);
|
||||||
}
|
}
|
||||||
|
|
||||||
jsblock->Set(NanNew<String>("hash"), NanNew<String>(cblock.GetHash().GetHex().c_str()));
|
jsblock->Set(NanNew<String>("hash"), NanNew<String>(cblock.GetHash().GetHex().c_str()));
|
||||||
@ -2878,9 +2881,9 @@ cblock_to_jsblock(const CBlock& cblock, CBlockIndex* cblock_index, Local<Object>
|
|||||||
jsblock->Set(NanNew<String>("hex"), NanNew<String>(strHex));
|
jsblock->Set(NanNew<String>("hex"), NanNew<String>(strHex));
|
||||||
|
|
||||||
// Freed up elsewhere:
|
// Freed up elsewhere:
|
||||||
// if (isNew) {
|
if (is_allocated) {
|
||||||
// delete cblock_index;
|
delete cblock_index;
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user