Skip to content

Commit b16cc77

Browse files
committed
simplify buffer read/write functions
1 parent 4bbece7 commit b16cc77

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

buffer.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ inline void buffer_read_block(unsigned char*& p, void* dest, size_t size) {
1212
template<typename T>
1313
inline T buffer_read(unsigned char*& p) {
1414
T ret{};
15-
buffer_read_block(p, &ret, sizeof(T));
15+
std::memcpy(&ret, p, sizeof(T));
16+
p += sizeof(T);
1617
return ret;
1718
}
1819

@@ -22,7 +23,8 @@ inline void buffer_write_block(unsigned char*& p, const void* src, size_t size)
2223
}
2324
template<typename T>
2425
inline void buffer_write(unsigned char*& p, T value) {
25-
buffer_write_block(p, &value, sizeof(T));
26+
std::memcpy(p, &value, sizeof(T));
27+
p += sizeof(T);
2628
}
2729

2830
inline void vector_write_block(std::vector<unsigned char>& buffer, const void* src, size_t size) {

0 commit comments

Comments
 (0)