Skip to content

Commit bae4561

Browse files
committed
scripted-diff: rename BytePtr to AsBytePtr
Building with iPhoneOS SDK fails because it also has `BytePtr` defined in /usr/include/MacTypes.h. -BEGIN VERIFY SCRIPT- sed -i 's/BytePtr/AsBytePtr/' $(git grep -l "BytePtr" src) -END VERIFY SCRIPT-
1 parent a19f641 commit bae4561

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

src/serialize.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -472,10 +472,10 @@ struct CustomUintFormatter
472472
if (v < 0 || v > MAX) throw std::ios_base::failure("CustomUintFormatter value out of range");
473473
if (BigEndian) {
474474
uint64_t raw = htobe64(v);
475-
s.write({BytePtr(&raw) + 8 - Bytes, Bytes});
475+
s.write({AsBytePtr(&raw) + 8 - Bytes, Bytes});
476476
} else {
477477
uint64_t raw = htole64(v);
478-
s.write({BytePtr(&raw), Bytes});
478+
s.write({AsBytePtr(&raw), Bytes});
479479
}
480480
}
481481

@@ -485,10 +485,10 @@ struct CustomUintFormatter
485485
static_assert(std::numeric_limits<U>::max() >= MAX && std::numeric_limits<U>::min() <= 0, "Assigned type too small");
486486
uint64_t raw = 0;
487487
if (BigEndian) {
488-
s.read({BytePtr(&raw) + 8 - Bytes, Bytes});
488+
s.read({AsBytePtr(&raw) + 8 - Bytes, Bytes});
489489
v = static_cast<I>(be64toh(raw));
490490
} else {
491-
s.read({BytePtr(&raw), Bytes});
491+
s.read({AsBytePtr(&raw), Bytes});
492492
v = static_cast<I>(le64toh(raw));
493493
}
494494
}

src/span.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -245,19 +245,19 @@ T& SpanPopBack(Span<T>& span)
245245

246246
//! Convert a data pointer to a std::byte data pointer.
247247
//! Where possible, please use the safer AsBytes helpers.
248-
inline const std::byte* BytePtr(const void* data) { return reinterpret_cast<const std::byte*>(data); }
249-
inline std::byte* BytePtr(void* data) { return reinterpret_cast<std::byte*>(data); }
248+
inline const std::byte* AsBytePtr(const void* data) { return reinterpret_cast<const std::byte*>(data); }
249+
inline std::byte* AsBytePtr(void* data) { return reinterpret_cast<std::byte*>(data); }
250250

251251
// From C++20 as_bytes and as_writeable_bytes
252252
template <typename T>
253253
Span<const std::byte> AsBytes(Span<T> s) noexcept
254254
{
255-
return {BytePtr(s.data()), s.size_bytes()};
255+
return {AsBytePtr(s.data()), s.size_bytes()};
256256
}
257257
template <typename T>
258258
Span<std::byte> AsWritableBytes(Span<T> s) noexcept
259259
{
260-
return {BytePtr(s.data()), s.size_bytes()};
260+
return {AsBytePtr(s.data()), s.size_bytes()};
261261
}
262262

263263
template <typename V>

src/wallet/bdb.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -683,10 +683,10 @@ bool BerkeleyBatch::ReadAtCursor(CDataStream& ssKey, CDataStream& ssValue, bool&
683683
// Convert to streams
684684
ssKey.SetType(SER_DISK);
685685
ssKey.clear();
686-
ssKey.write({BytePtr(datKey.get_data()), datKey.get_size()});
686+
ssKey.write({AsBytePtr(datKey.get_data()), datKey.get_size()});
687687
ssValue.SetType(SER_DISK);
688688
ssValue.clear();
689-
ssValue.write({BytePtr(datValue.get_data()), datValue.get_size()});
689+
ssValue.write({AsBytePtr(datValue.get_data()), datValue.get_size()});
690690
return true;
691691
}
692692

@@ -758,7 +758,7 @@ bool BerkeleyBatch::ReadKey(CDataStream&& key, CDataStream& value)
758758
SafeDbt datValue;
759759
int ret = pdb->get(activeTxn, datKey, datValue, 0);
760760
if (ret == 0 && datValue.get_data() != nullptr) {
761-
value.write({BytePtr(datValue.get_data()), datValue.get_size()});
761+
value.write({AsBytePtr(datValue.get_data()), datValue.get_size()});
762762
return true;
763763
}
764764
return false;

src/wallet/sqlite.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ bool SQLiteBatch::ReadKey(CDataStream&& key, CDataStream& value)
405405
return false;
406406
}
407407
// Leftmost column in result is index 0
408-
const std::byte* data{BytePtr(sqlite3_column_blob(m_read_stmt, 0))};
408+
const std::byte* data{AsBytePtr(sqlite3_column_blob(m_read_stmt, 0))};
409409
size_t data_size(sqlite3_column_bytes(m_read_stmt, 0));
410410
value.write({data, data_size});
411411

@@ -497,10 +497,10 @@ bool SQLiteBatch::ReadAtCursor(CDataStream& key, CDataStream& value, bool& compl
497497
}
498498

499499
// Leftmost column in result is index 0
500-
const std::byte* key_data{BytePtr(sqlite3_column_blob(m_cursor_stmt, 0))};
500+
const std::byte* key_data{AsBytePtr(sqlite3_column_blob(m_cursor_stmt, 0))};
501501
size_t key_data_size(sqlite3_column_bytes(m_cursor_stmt, 0));
502502
key.write({key_data, key_data_size});
503-
const std::byte* value_data{BytePtr(sqlite3_column_blob(m_cursor_stmt, 1))};
503+
const std::byte* value_data{AsBytePtr(sqlite3_column_blob(m_cursor_stmt, 1))};
504504
size_t value_data_size(sqlite3_column_bytes(m_cursor_stmt, 1));
505505
value.write({value_data, value_data_size});
506506
return true;

0 commit comments

Comments
 (0)