remove safety checks, for some reason

This commit is contained in:
Andrew Dutcher 2016-10-11 13:07:14 -07:00
parent ea54204952
commit 80f35d3b2b
2 changed files with 4 additions and 19 deletions

View file

@ -247,10 +247,7 @@ struct uc_struct {
// Metadata stub for the variable-size cpu context used with uc_context_*()
struct uc_context {
uc_arch arch;
uc_mode mode;
size_t size;
bool used;
char data[0];
};

20
uc.c
View file

@ -1181,9 +1181,6 @@ uc_err uc_context_alloc(uc_engine *uc, uc_context **context)
*_context = malloc(size + sizeof(uc_context));
if (*_context) {
(*_context)->size = size;
(*_context)->arch = uc->arch;
(*_context)->mode = uc->mode;
(*_context)->used = false;
return UC_ERR_OK;
} else {
return UC_ERR_NOMEM;
@ -1201,23 +1198,14 @@ UNICORN_EXPORT
uc_err uc_context_save(uc_engine *uc, uc_context *context)
{
struct uc_context *_context = context;
if (_context->arch != uc->arch || _context->mode != uc->mode) {
return UC_ERR_ARG;
} else {
memcpy(_context->data, uc->cpu->env_ptr, _context->size);
_context->used = true;
return UC_ERR_OK;
}
memcpy(_context->data, uc->cpu->env_ptr, _context->size);
return UC_ERR_OK;
}
UNICORN_EXPORT
uc_err uc_context_restore(uc_engine *uc, uc_context *context)
{
struct uc_context *_context = context;
if (_context->arch != uc->arch || _context->mode != uc->mode || !_context->used) {
return UC_ERR_ARG;
} else {
memcpy(uc->cpu->env_ptr, _context->data, _context->size);
return UC_ERR_OK;
}
memcpy(uc->cpu->env_ptr, _context->data, _context->size);
return UC_ERR_OK;
}