21
common/resource_traits/unicorn/unicorn_alloc.hpp
Normal file
21
common/resource_traits/unicorn/unicorn_alloc.hpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include <unicorn/unicorn.h>
|
||||
|
||||
namespace nkg::resource_traits::unicorn {
|
||||
|
||||
struct unicorn_alloc {
|
||||
using handle_t = void*;
|
||||
|
||||
static constexpr handle_t invalid_value = nullptr;
|
||||
|
||||
[[nodiscard]]
|
||||
static bool is_valid(const handle_t& handle) noexcept {
|
||||
return handle != invalid_value;
|
||||
}
|
||||
|
||||
static void release(const handle_t& handle) {
|
||||
uc_free(handle);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
21
common/resource_traits/unicorn/unicorn_handle.hpp
Normal file
21
common/resource_traits/unicorn/unicorn_handle.hpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include <unicorn/unicorn.h>
|
||||
|
||||
namespace nkg::resource_traits::unicorn {
|
||||
|
||||
struct unicorn_handle {
|
||||
using handle_t = uc_engine*;
|
||||
|
||||
static constexpr handle_t invalid_value = nullptr;
|
||||
|
||||
[[nodiscard]]
|
||||
static bool is_valid(const handle_t& handle) noexcept {
|
||||
return handle != invalid_value;
|
||||
}
|
||||
|
||||
static void release(const handle_t& handle) {
|
||||
uc_close(handle);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user