diff options
| author | Peter LaFosse <peter@vector35.com> | 2018-12-03 22:20:28 -0500 |
|---|---|---|
| committer | Peter LaFosse <peter@vector35.com> | 2018-12-13 13:32:18 -0500 |
| commit | 231afab8b0ba6c8c9eff879681c52724b6688c18 (patch) | |
| tree | 38026cfa20f34702b7267e9c397652119f27ebe7 /flowgraphnode.cpp | |
| parent | 7357dd114a145ca64e7356233c3cb8b9dd9eae84 (diff) | |
Commonize all InstructionTextToken generation
Diffstat (limited to 'flowgraphnode.cpp')
| -rw-r--r-- | flowgraphnode.cpp | 39 |
1 files changed, 3 insertions, 36 deletions
diff --git a/flowgraphnode.cpp b/flowgraphnode.cpp index 60912df1..649e4941 100644 --- a/flowgraphnode.cpp +++ b/flowgraphnode.cpp @@ -95,26 +95,12 @@ const vector<DisassemblyTextLine>& FlowGraphNode::GetLines() line.addr = lines[i].addr; line.instrIndex = lines[i].instrIndex; line.highlight = lines[i].highlight; - line.tokens.reserve(lines[i].count); - for (size_t j = 0; j < lines[i].count; j++) - { - InstructionTextToken token; - token.type = lines[i].tokens[j].type; - token.text = lines[i].tokens[j].text; - token.value = lines[i].tokens[j].value; - token.size = lines[i].tokens[j].size; - token.operand = lines[i].tokens[j].operand; - token.context = lines[i].tokens[j].context; - token.confidence = lines[i].tokens[j].confidence; - token.address = lines[i].tokens[j].address; - line.tokens.push_back(token); - } + line.tokens = InstructionTextToken::ConvertInstructionTextTokenList(lines[i].tokens, lines[i].count); result.push_back(line); } BNFreeDisassemblyTextLines(lines, count); m_cachedLines = result; - m_cachedLinesValid = true; return m_cachedLines; } @@ -128,31 +114,12 @@ void FlowGraphNode::SetLines(const vector<DisassemblyTextLine>& lines) buf[i].addr = line.addr; buf[i].instrIndex = line.instrIndex; buf[i].highlight = line.highlight; - buf[i].tokens = new BNInstructionTextToken[line.tokens.size()]; + buf[i].tokens = InstructionTextToken::CreateInstructionTextTokenList(line.tokens); buf[i].count = line.tokens.size(); - for (size_t j = 0; j < line.tokens.size(); j++) - { - const InstructionTextToken& token = line.tokens[j]; - buf[i].tokens[j].type = token.type; - buf[i].tokens[j].text = BNAllocString(token.text.c_str()); - buf[i].tokens[j].value = token.value; - buf[i].tokens[j].size = token.size; - buf[i].tokens[j].operand = token.operand; - buf[i].tokens[j].context = token.context; - buf[i].tokens[j].confidence = token.confidence; - buf[i].tokens[j].address = token.address; - } } BNSetFlowGraphNodeLines(m_object, buf, lines.size()); - - for (size_t i = 0; i < lines.size(); i++) - { - for (size_t j = 0; j < buf[i].count; j++) - BNFreeString(buf[i].tokens[j].text); - delete[] buf[i].tokens; - } - delete[] buf; + BNFreeDisassemblyTextLines(buf, lines.size()); m_cachedLines = lines; m_cachedLinesValid = true; |
