Skip to content

Commit

Permalink
Merge pull request #406 from ethereum/deprecated_is_zero
Browse files Browse the repository at this point in the history
cpp: Fallback to evmc::is_zero() in case the deprecated ::is_zero() is used
  • Loading branch information
chfast authored Aug 19, 2019
2 parents 799b8ff + f0bc605 commit 1cfc035
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ and this project adheres to [Semantic Versioning].

- Added `LoadAndConfigure` method to the Go API.
[[#404](https://github.com/ethereum/evmc/pull/404)]

### Deprecated

- Previously deprecated `is_zero()` helper has been removed,
but replaced with new `evmc::is_zero()` in API compatible way.
[[#406](https://github.com/ethereum/evmc/pull/406)]

### Fixed

Expand Down
20 changes: 3 additions & 17 deletions include/evmc/helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
*/
#pragma once

#include <evmc/evmc.h>
#include <evmc/evmc.hpp>

#include <cstring>
#include <functional>

using evmc::is_zero;

/// The comparator for std::map<evmc_address, ...>.
EVMC_DEPRECATED
inline bool operator<(const evmc_address& a, const evmc_address& b)
Expand Down Expand Up @@ -45,22 +47,6 @@ inline bool operator==(const evmc_bytes32& a, const evmc_bytes32& b)
return std::memcmp(a.bytes, b.bytes, sizeof(a.bytes)) == 0;
}

/// Check if the address is zero (all bytes are zeros).
EVMC_DEPRECATED
inline bool is_zero(const evmc_address& address) noexcept
{
constexpr auto zero = evmc_address{};
return std::memcmp(address.bytes, zero.bytes, sizeof(zero.bytes)) == 0;
}

/// Check if the hash is zero (all bytes are zeros).
EVMC_DEPRECATED
inline bool is_zero(const evmc_bytes32& x) noexcept
{
constexpr auto zero = evmc_bytes32{};
return std::memcmp(x.bytes, zero.bytes, sizeof(zero.bytes)) == 0;
}

/// Parameters for the fnv1a hash function, specialized by the hash result size (size_t).
///
/// The values for the matching size are taken from
Expand Down

0 comments on commit 1cfc035

Please sign in to comment.