mirror of
https://github.com/capstone-engine/capstone.git
synced 2024-11-23 05:29:53 +00:00
replace offset_of with offsetof from stddef.h
This commit is contained in:
parent
4fe59955d6
commit
cae09bf543
@ -292,7 +292,7 @@ static DecodeStatus getInstruction(MCInst *MI,
|
||||
(code[1] << 8) | (code[0] << 0);
|
||||
|
||||
if (MI->flat_insn->detail) {
|
||||
memset(&MI->flat_insn->detail->ppc, 0, offset_of(cs_ppc, operands));
|
||||
memset(&MI->flat_insn->detail->ppc, 0, offsetof(cs_ppc, operands));
|
||||
}
|
||||
|
||||
result = decodeInstruction_4(DecoderTable32, MI, insn, Address, 4);
|
||||
|
@ -232,7 +232,7 @@ bool Sparc_getInstruction(csh ud, const uint8_t *code, size_t code_len, MCInst *
|
||||
return MCDisassembler_Fail;
|
||||
|
||||
if (MI->flat_insn->detail) {
|
||||
memset(&MI->flat_insn->detail->sparc, 0, offset_of(cs_sparc, operands));
|
||||
memset(&MI->flat_insn->detail->sparc, 0, offsetof(cs_sparc, operands));
|
||||
}
|
||||
|
||||
Result = decodeInstruction_4(DecoderTableSparc32, MI, Insn, address,
|
||||
|
@ -322,7 +322,7 @@ bool SystemZ_getInstruction(csh ud, const uint8_t *code, size_t code_len, MCInst
|
||||
return MCDisassembler_Fail;
|
||||
|
||||
if (MI->flat_insn->detail) {
|
||||
memset(&MI->flat_insn->detail->sysz, 0, offset_of(cs_sysz, operands));
|
||||
memset(&MI->flat_insn->detail->sysz, 0, offsetof(cs_sysz, operands));
|
||||
}
|
||||
|
||||
memcpy(Bytes, code, *size);
|
||||
|
@ -706,7 +706,7 @@ bool X86_getInstruction(csh ud, const uint8_t *code, size_t code_len,
|
||||
info.size = code_len;
|
||||
info.offset = address;
|
||||
|
||||
memset(&insn, 0, offset_of(InternalInstruction, reader));
|
||||
memset(&insn, 0, offsetof(InternalInstruction, reader));
|
||||
|
||||
if (instr->flat_insn->detail) {
|
||||
instr->flat_insn->detail->x86.op_count = 0;
|
||||
|
@ -738,7 +738,7 @@ bool XCore_getInstruction(csh ud, const uint8_t *code, size_t code_len, MCInst *
|
||||
}
|
||||
|
||||
if (MI->flat_insn->detail) {
|
||||
memset(&MI->flat_insn->detail->xcore, 0, offset_of(cs_xcore, operands));
|
||||
memset(&MI->flat_insn->detail->xcore, 0, offsetof(cs_xcore, operands));
|
||||
}
|
||||
|
||||
// Calling the auto-generated decoder function.
|
||||
|
2
cs.c
2
cs.c
@ -488,7 +488,7 @@ size_t cs_disasm_ex(csh ud, const uint8_t *buffer, size_t size, uint64_t offset,
|
||||
}
|
||||
|
||||
total = tmp;
|
||||
insn_cache = total + total_size - (sizeof(cs_insn) * INSN_CACHE_SIZE);
|
||||
insn_cache = (cs_insn *)((char *)total + total_size - (sizeof(cs_insn) * INSN_CACHE_SIZE));
|
||||
|
||||
// reset f back to 0
|
||||
f = 0;
|
||||
|
3
utils.h
3
utils.h
@ -4,6 +4,7 @@
|
||||
#ifndef CS_UTILS_H
|
||||
#define CS_UTILS_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include "include/capstone.h"
|
||||
#include "cs_priv.h"
|
||||
|
||||
@ -47,7 +48,5 @@ char *cs_strdup(const char *str);
|
||||
|
||||
#define MIN(x, y) ((x) < (y) ? (x) : (y))
|
||||
|
||||
#define offset_of(st, member) __builtin_offsetof(st, member)
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user