| 512 | |
| 513 | CAPSTONE_EXPORT |
| 514 | cs_err CAPSTONE_API cs_close(csh *handle) |
| 515 | { |
| 516 | struct cs_struct *ud; |
| 517 | struct insn_mnem *next, *tmp; |
| 518 | |
| 519 | if (*handle == 0) |
| 520 | // invalid handle |
| 521 | return CS_ERR_CSH; |
| 522 | |
| 523 | ud = (struct cs_struct *)(*handle); |
| 524 | |
| 525 | if (ud->printer_info) |
| 526 | cs_mem_free(ud->printer_info); |
| 527 | |
| 528 | // free the linked list of customized mnemonic |
| 529 | tmp = ud->mnem_list; |
| 530 | while(tmp) { |
| 531 | next = tmp->next; |
| 532 | cs_mem_free(tmp); |
| 533 | tmp = next; |
| 534 | } |
| 535 | |
| 536 | cs_mem_free(ud->insn_cache); |
| 537 | cs_mem_free(ud->x86_insn_lut); |
| 538 | cs_mem_free(ud->x86_insn_reg_lut); |
| 539 | |
| 540 | memset(ud, 0, sizeof(*ud)); |
| 541 | cs_mem_free(ud); |
| 542 | |
| 543 | // invalidate this handle by ZERO out its value. |
| 544 | // this is to make sure it is unusable after cs_close() |
| 545 | *handle = 0; |
| 546 | |
| 547 | return CS_ERR_OK; |
| 548 | } |
| 549 | |
| 550 | // replace str1 in target with str2; target starts with str1 |
| 551 | // output is put into result (which is array of char with size CS_MNEMONIC_SIZE) |
no outgoing calls
searching dependent graphs…