| 1083 | } |
| 1084 | |
| 1085 | CAPSTONE_EXPORT |
| 1086 | cs_insn * CAPSTONE_API cs_malloc(csh ud) |
| 1087 | { |
| 1088 | cs_insn *insn; |
| 1089 | struct cs_struct *handle = (struct cs_struct *)(uintptr_t)ud; |
| 1090 | |
| 1091 | insn = cs_mem_malloc(sizeof(cs_insn)); |
| 1092 | if (!insn) { |
| 1093 | // insufficient memory |
| 1094 | handle->errnum = CS_ERR_MEM; |
| 1095 | return NULL; |
| 1096 | } else { |
| 1097 | if (handle->detail) { |
| 1098 | // allocate memory for @detail pointer |
| 1099 | insn->detail = cs_mem_malloc(sizeof(cs_detail)); |
| 1100 | if (insn->detail == NULL) { // insufficient memory |
| 1101 | cs_mem_free(insn); |
| 1102 | handle->errnum = CS_ERR_MEM; |
| 1103 | return NULL; |
| 1104 | } |
| 1105 | } else |
| 1106 | insn->detail = NULL; |
| 1107 | } |
| 1108 | |
| 1109 | return insn; |
| 1110 | } |
| 1111 | |
| 1112 | // iterator for instruction "single-stepping" |
| 1113 | CAPSTONE_EXPORT |
no outgoing calls
searching dependent graphs…