replace offset_of with offsetof from stddef.h

This commit is contained in:
Nguyen Anh Quynh 2014-06-17 14:58:39 +08:00
parent 4fe59955d6
commit cae09bf543
7 changed files with 7 additions and 8 deletions

View File

@ -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);

View File

@ -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,

View File

@ -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);

View File

@ -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;

View File

@ -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
View File

@ -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;

View File

@ -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