crosvm/data_model
Chirantan Ekbote f4d6014c41 data_model: Don't heap allocate in DataInit::from_reader
We can use MaybeUninit instead of heap allocation to ensure that our
buffer has the proper size and alignment. `from_reader` is used for
every message in the fs device and this saves us some unnecessary small
heap allocations.

Switch Reader::read_obj to use this method so that we don't have
multiple implementations of the same thing. This also fixes some
unsoundness in read_obj where we were creating a `&mut [u8]` out of
uninitialized data.

BUG=none
TEST=unit tests

Change-Id: I1fa66de11974e2fe3a8dfb4b7ab4b210ecf395d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3109088
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2021-08-23 11:59:16 +00:00
..
src data_model: Don't heap allocate in DataInit::from_reader 2021-08-23 11:59:16 +00:00
Cargo.toml data_model: make endian types Serialize and Deserialize 2021-03-04 11:26:31 +00:00