mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-21 04:16:12 +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() {}
|
||||||
|
|
||||||
BasicBlockHighlighter::~BasicBlockHighlighter()
|
|
||||||
{
|
|
||||||
for (BasicBlockIt itr = bbMap.begin(); itr != bbMap.end(); ++itr) {
|
|
||||||
delete itr->second;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Highlight the basic block at address
|
* @brief Highlight the basic block at address
|
||||||
*/
|
*/
|
||||||
void BasicBlockHighlighter::highlight(RVA address, const QColor &color)
|
void BasicBlockHighlighter::highlight(RVA address, const QColor &color)
|
||||||
{
|
{
|
||||||
BasicBlock *block = new BasicBlock;
|
BasicBlock block;
|
||||||
block->address = address;
|
block.address = address;
|
||||||
block->color = color;
|
block.color = color;
|
||||||
bbMap[address] = block;
|
bbMap[address] = block;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,13 +26,11 @@ void BasicBlockHighlighter::clear(RVA address)
|
|||||||
*
|
*
|
||||||
* If there is nothing to highlight at specified address, returns nullptr
|
* If there is nothing to highlight at specified address, returns nullptr
|
||||||
*/
|
*/
|
||||||
BasicBlock *BasicBlockHighlighter::getBasicBlock(RVA address)
|
BasicBlockHighlighter::BasicBlock *BasicBlockHighlighter::getBasicBlock(RVA address)
|
||||||
{
|
{
|
||||||
BasicBlockIt it;
|
auto it = bbMap.find(address);
|
||||||
|
|
||||||
it = bbMap.find(address);
|
|
||||||
if (it != bbMap.end()) {
|
if (it != bbMap.end()) {
|
||||||
return it->second;
|
return &it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -6,26 +6,23 @@ class BasicBlockHighlighter;
|
|||||||
#include "Cutter.h"
|
#include "Cutter.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
class BasicBlockHighlighter
|
||||||
|
{
|
||||||
|
public:
|
||||||
struct BasicBlock
|
struct BasicBlock
|
||||||
{
|
{
|
||||||
RVA address;
|
RVA address;
|
||||||
QColor color;
|
QColor color;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::map<RVA, BasicBlock *>::iterator BasicBlockIt;
|
|
||||||
|
|
||||||
class BasicBlockHighlighter
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
BasicBlockHighlighter();
|
BasicBlockHighlighter();
|
||||||
~BasicBlockHighlighter();
|
|
||||||
|
|
||||||
void highlight(RVA address, const QColor &color);
|
void highlight(RVA address, const QColor &color);
|
||||||
void clear(RVA address);
|
void clear(RVA address);
|
||||||
BasicBlock *getBasicBlock(RVA address);
|
BasicBlock *getBasicBlock(RVA address);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<RVA, BasicBlock *> bbMap;
|
std::map<RVA, BasicBlock> bbMap;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BASICBLOCKHIGHLIGHTER_H
|
#endif // BASICBLOCKHIGHLIGHTER_H
|
||||||
|
Loading…
Reference in New Issue
Block a user