1
0
mirror of https://github.com/Zygo/bees.git synced 2025-06-16 17:46:16 +02:00

fs: deprecate vector<char>

Use uint8_t when we mean uint8_t, i.e. vector<uint8_t> instead of
vector<char>.

Add a template parameter instead of vector so we can swap in a
non-copying data type.

Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
Zygo Blaxell
2020-11-04 21:02:37 -05:00
parent 180bb60cde
commit f45e379802
3 changed files with 29 additions and 27 deletions

View File

@ -19,13 +19,13 @@ namespace crucible {
memset(that, 0, sizeof(Base));
}
// Copy a base class object (usually a C struct) into a vector<char>
// Copy a base class object (usually a C struct) into a vector<uint8_t>
template <class Base>
vector<char>
vector<uint8_t>
vector_copy_struct(Base *that)
{
const char *begin_that = reinterpret_cast<const char *>(static_cast<const Base *>(that));
return vector<char>(begin_that, begin_that + sizeof(Base));
const uint8_t *begin_that = reinterpret_cast<const uint8_t *>(static_cast<const Base *>(that));
return vector<uint8_t>(begin_that, begin_that + sizeof(Base));
}
// int->hex conversion with sprintf
@ -60,7 +60,7 @@ namespace crucible {
ptrdiff_t
pointer_distance(const P1 *a, const P2 *b)
{
return reinterpret_cast<const char *>(a) - reinterpret_cast<const char *>(b);
return reinterpret_cast<const uint8_t *>(a) - reinterpret_cast<const uint8_t *>(b);
}
};