From 79aad8ae084a4e4c35a37cf4ec37895d581463e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Wed, 6 Nov 2019 13:20:06 +0100 Subject: [PATCH] cpp: Return reference (not pointer) from Host::get_interface() --- examples/example_host.cpp | 2 +- include/evmc/evmc.hpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/example_host.cpp b/examples/example_host.cpp index 64545a0..ff1c987 100644 --- a/examples/example_host.cpp +++ b/examples/example_host.cpp @@ -162,7 +162,7 @@ extern "C" { const evmc_host_interface* example_host_get_interface() { - return evmc::Host::get_interface(); + return &evmc::Host::get_interface(); } evmc_host_context* example_host_create_context(evmc_tx_context tx_context) diff --git a/include/evmc/evmc.hpp b/include/evmc/evmc.hpp index 2e3af07..1d2d9fa 100644 --- a/include/evmc/evmc.hpp +++ b/include/evmc/evmc.hpp @@ -596,8 +596,8 @@ class Host : public HostInterface { public: /// Provides access to the global host interface. - /// @returns Pointer to the host interface object. - static const evmc_host_interface* get_interface() noexcept; + /// @returns Reference to the host interface object. + static const evmc_host_interface& get_interface() noexcept; /// Converts the Host object to the opaque host context pointer. /// @returns Pointer to evmc_host_context. @@ -698,7 +698,7 @@ inline void emit_log(evmc_host_context* h, } } // namespace internal -inline const evmc_host_interface* Host::get_interface() noexcept +inline const evmc_host_interface& Host::get_interface() noexcept { static constexpr evmc_host_interface interface{ ::evmc::internal::account_exists, ::evmc::internal::get_storage, @@ -707,7 +707,7 @@ inline const evmc_host_interface* Host::get_interface() noexcept ::evmc::internal::copy_code, ::evmc::internal::selfdestruct, ::evmc::internal::call, ::evmc::internal::get_tx_context, ::evmc::internal::get_block_hash, ::evmc::internal::emit_log}; - return &interface; + return interface; } } // namespace evmc