-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cs_buffer. Breaking API change. #2367
Conversation
363a344
to
ba071f4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is one problem in |
I've updated python bindings and review is appreciated. |
9b792b2
to
01397fe
Compare
please avoid breaking API |
Remove cs_malloc() and cs_free(). API change unifies disassembly process. Before, there were two separate functions to disassemble one instruction at a time in a loop and many instructions into a dynamic buffer. Commit will introduce user allocatable buffer that can be used in both situations with one function. cs_disasm_iter() is a tiny wrapper around cs_disasm(). Updating the use of cs_disasm_iter(): // old api cs_insn *insn = cs_malloc(handle); while (cs_disasm_iter(handle, &code, &code_size, &ip, insn)) { disassembled_instructions += 1; } cs_free(insn); Must be changed to: // new api cs_buffer *buffer = cs_buffer_new(1); // create buffer with 1 element while (cs_disasm_iter(handle, &code, &code_size, &ip, buffer)) { cs_insn *insn = &buffer->insn[0]; // get first insn in a buffer disassembled_instructions += 1; } cs_buffer_free(buffer); // free buffer Updating the use of cs_disasm() is straightforward, just use cs_buffer_new(0) to create a buffer and pass it to cs_disasm().
I'm closing PRs. We'll think about what can be done. |
Remove
cs_malloc()
andcs_free()
.cs_disasm_iter()
is a tiny wrapper aroundcs_disasm(count=1)
.Your checklist for this pull request
Detailed description
API change unifies disassembly process. Before, there were two separate functions to disassemble one instruction at a time in a loop and many instructions into a dynamic buffer. Commit will introduce user allocatable buffer that can be used in both situations with one function.
Updating the use of
cs_disasm_iter()
is a little more complicated thancs_disasm()
:Must be changed to:
Updating the use of
cs_disasm()
is straightforward, just usecs_buffer_new(0)
to create a buffer and pass it tocs_disasm()
.Benchmarks
Test plan
Update bindings and user software.
Closing issues
...