Implement uc_context_free (#1336)

* Implement uc_context_free

* Use uc_context_free for python bindings

* Format code

* Simplify code

* Move next,context inside while loop

* Add my name to CREDITS.TXT
This commit is contained in:
lazymio
2020-09-24 22:28:55 +08:00
committed by GitHub
parent 4441394258
commit 1044403d38
5 changed files with 54 additions and 8 deletions

View File

@ -707,10 +707,12 @@ UNICORN_EXPORT
uc_err uc_context_alloc(uc_engine *uc, uc_context **context);
/*
Free the memory allocated by uc_context_alloc & uc_mem_regions.
Free the memory allocated by uc_mem_regions.
WARNING: After Unicorn 1.0.1rc5, the memory allocated by uc_context_alloc should
be free-ed by uc_context_free(). Calling uc_free() may still work, but the result
is **undefined**.
@mem: memory allocated by uc_context_alloc (returned in *context), or
by uc_mem_regions (returned in *regions)
@mem: memory allocated by uc_mem_regions (returned in *regions).
@return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
for detailed error).
@ -738,7 +740,7 @@ uc_err uc_context_save(uc_engine *uc, uc_context *context);
state saved by uc_context_save().
@uc: handle returned by uc_open()
@buffer: handle returned by uc_context_alloc that has been used with uc_context_save
@context: handle returned by uc_context_alloc that has been used with uc_context_save
@return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
for detailed error).
@ -758,6 +760,18 @@ uc_err uc_context_restore(uc_engine *uc, uc_context *context);
UNICORN_EXPORT
size_t uc_context_size(uc_engine *uc);
/*
Free the context allocated by uc_context_alloc().
@context: handle returned by uc_context_alloc()
@return UC_ERR_OK on success, or other value on failure (refer to uc_err enum
for detailed error).
*/
UNICORN_EXPORT
uc_err uc_context_free(uc_context *context);
#ifdef __cplusplus
}
#endif