mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-18 19:06:10 +00:00
Don't leak memory in bb highlighter.
This commit is contained in:
parent
fd42ddb0bb
commit
77b93fbab0
@ -2,21 +2,14 @@
|
||||
|
||||
BasicBlockHighlighter::BasicBlockHighlighter() {}
|
||||
|
||||
BasicBlockHighlighter::~BasicBlockHighlighter()
|
||||
{
|
||||
for (BasicBlockIt itr = bbMap.begin(); itr != bbMap.end(); ++itr) {
|
||||
delete itr->second;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Highlight the basic block at address
|
||||
*/
|
||||
void BasicBlockHighlighter::highlight(RVA address, const QColor &color)
|
||||
{
|
||||
BasicBlock *block = new BasicBlock;
|
||||
block->address = address;
|
||||
block->color = color;
|
||||
BasicBlock block;
|
||||
block.address = address;
|
||||
block.color = color;
|
||||
bbMap[address] = block;
|
||||
}
|
||||
|
||||
@ -33,13 +26,11 @@ void BasicBlockHighlighter::clear(RVA address)
|
||||
*
|
||||
* If there is nothing to highlight at specified address, returns nullptr
|
||||
*/
|
||||
BasicBlock *BasicBlockHighlighter::getBasicBlock(RVA address)
|
||||
BasicBlockHighlighter::BasicBlock *BasicBlockHighlighter::getBasicBlock(RVA address)
|
||||
{
|
||||
BasicBlockIt it;
|
||||
|
||||
it = bbMap.find(address);
|
||||
auto it = bbMap.find(address);
|
||||
if (it != bbMap.end()) {
|
||||
return it->second;
|
||||
return &it->second;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
@ -6,26 +6,23 @@ class BasicBlockHighlighter;
|
||||
#include "Cutter.h"
|
||||
#include <map>
|
||||
|
||||
struct BasicBlock
|
||||
{
|
||||
RVA address;
|
||||
QColor color;
|
||||
};
|
||||
|
||||
typedef std::map<RVA, BasicBlock *>::iterator BasicBlockIt;
|
||||
|
||||
class BasicBlockHighlighter
|
||||
{
|
||||
public:
|
||||
struct BasicBlock
|
||||
{
|
||||
RVA address;
|
||||
QColor color;
|
||||
};
|
||||
|
||||
BasicBlockHighlighter();
|
||||
~BasicBlockHighlighter();
|
||||
|
||||
void highlight(RVA address, const QColor &color);
|
||||
void clear(RVA address);
|
||||
BasicBlock *getBasicBlock(RVA address);
|
||||
|
||||
private:
|
||||
std::map<RVA, BasicBlock *> bbMap;
|
||||
std::map<RVA, BasicBlock> bbMap;
|
||||
};
|
||||
|
||||
#endif // BASICBLOCKHIGHLIGHTER_H
|
||||
|
Loading…
Reference in New Issue
Block a user