Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
poor-circle committed Nov 22, 2023
1 parent 6205c57 commit 7561770
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
5 changes: 1 addition & 4 deletions include/ylt/struct_pack/endian_wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,7 @@ bool read_wrapper(reader_t& reader, char* SP_RESTRICT data) {
template <typename reader_t>
bool read_bytes_array(reader_t& reader, char* SP_RESTRICT data,
std::size_t length) {
if SP_UNLIKELY (length >= PTRDIFF_MAX)
unreachable();
else
return static_cast<bool>(reader.read(data, length));
return static_cast<bool>(reader.read(data, length));
}
template <std::size_t block_size, typename reader_t, typename T>
bool low_bytes_read_wrapper(reader_t& reader, T& elem) {
Expand Down
15 changes: 6 additions & 9 deletions include/ylt/struct_pack/unpacker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -993,15 +993,12 @@ class unpacker {
}
else if constexpr (is_little_endian_copyable<sizeof(
value_type)>) {
if SP_UNLIKELY (mem_sz >= PTRDIFF_MAX)
unreachable();
else {
item.resize(size64);
if SP_UNLIKELY (!read_bytes_array(
reader_, (char *)item.data(),
size64 * sizeof(value_type))) {
return struct_pack::errc::no_buffer_space;
}

item.resize(size64);
if SP_UNLIKELY (!read_bytes_array(
reader_, (char *)item.data(),
size64 * sizeof(value_type))) {
return struct_pack::errc::no_buffer_space;
}
}
else {
Expand Down

0 comments on commit 7561770

Please sign in to comment.