diff options
author | Victor Hugo Vianna Silva <victor.vianna10@gmail.com> | 2025-01-29 17:09:35 +0000 |
---|---|---|
committer | Victor Hugo Vianna Silva <victor.vianna10@gmail.com> | 2025-01-29 17:26:12 +0000 |
commit | 4ee78d7ea98330f7d7599c42576ca99e3c6ff9c5 (patch) | |
tree | 5ceb2f8c7a6aa12d3aad31ca4e001174143a90ae | |
parent | e829478c6a3a55d8e5c1227e2678dcc18d518609 (diff) | |
download | leveldb-4ee78d7ea98330f7d7599c42576ca99e3c6ff9c5.tar.gz leveldb-4ee78d7ea98330f7d7599c42576ca99e3c6ff9c5.zip |
Reland changes accidentally reverted in 302786e
These changes
1) 2cc36eb - "[jumbo] Add begin()/end() to Slice."
2) 578eeb7 - "Fix invalid pointer arithmetic in Hash (#1222)"
were committed in the public repository but never got imported to
the internal Google repository. Later, cl/713346733 landed in the
internal repo. When tooling published the internal change as
302786e ("Fix C++23 compilation errors in leveldb"), it
accidentally reverted commits (1) and (2).
This change re-commits a bundled version of (1) and (2) in the
public repo. This will then be imported to the private repo,
leaving the 2 in sync.
-rw-r--r-- | include/leveldb/slice.h | 3 | ||||
-rw-r--r-- | util/hash.cc | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/include/leveldb/slice.h b/include/leveldb/slice.h index 37cb821..e97223a 100644 --- a/include/leveldb/slice.h +++ b/include/leveldb/slice.h @@ -51,6 +51,9 @@ class LEVELDB_EXPORT Slice { // Return true iff the length of the referenced data is zero bool empty() const { return size_ == 0; } + const char* begin() const { return data(); } + const char* end() const { return data() + size(); } + // Return the ith byte in the referenced data. // REQUIRES: n < size() char operator[](size_t n) const { diff --git a/util/hash.cc b/util/hash.cc index 8122fa8..fa252c7 100644 --- a/util/hash.cc +++ b/util/hash.cc @@ -27,7 +27,7 @@ uint32_t Hash(const char* data, size_t n, uint32_t seed) { uint32_t h = seed ^ (n * m); // Pick up four bytes at a time - while (data + 4 <= limit) { + while (limit - data >= 4) { uint32_t w = DecodeFixed32(data); data += 4; h += w; |