MCPcopy Create free account
hub / github.com/capstone-engine/capstone / cs_malloc

Function cs_malloc

cs.c:1085–1110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1083}
1084
1085CAPSTONE_EXPORT
1086cs_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"
1113CAPSTONE_EXPORT

Callers 5

mainFunction · 0.85
testFunction · 0.85
LLVMFuzzerTestOneInputFunction · 0.85
vbCapstone.cppFile · 0.85
test_iter.cFile · 0.85

Calls

no outgoing calls

Tested by 2

mainFunction · 0.68
testFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…