aquynh/capstone — pull request #183 by hlide (2014-09-26 18:03:02+00:00)
Title: Buffer allocation fixed and two features added through options

CS_OPT_INSN_CACHE_SIZE and CS_OPT_CHECKINSN.

(1) Buffer allocation had a weird allocation scheme. Now cs_disasm will resize the result buffer to the exact number of disassembled instructions when leaving.

(2) Option CS_OPT_INSN_CACHE_SIZE allows to set the initial and growing size of the buffer when calling cs_disasm. If the code to disassemble is pretty big, setting a bigger initial size will reduce the calls to realloc (that is, to reduce successive copies of an old huge block into a newly allocated block).

(3) Option CS_OPT_CHECKINSN allows to setup a user callback to call for each disassembled instructions. The user callback returns a boolean to tell cs_disasm to proceed with the next instruction or to stop disassembly.