Skip to content
This repository has been archived by the owner on Oct 26, 2022. It is now read-only.

Various netlink-proto Encoder impl fixes #168

Merged
merged 3 commits into from
Jun 14, 2021

Commits on Jun 6, 2021

  1. netlink-proto: optimize Encoder: calculate message length only once

    fe8cb5e introduced this when to_bytes()
    didn't return the size anymore.
    stbuehler committed Jun 6, 2021
    Configuration menu
    Copy the full SHA
    a1762f1 View commit details
    Browse the repository at this point in the history
  2. netlink-proto: fix Encoder allocation

    - don't allocate in 2048 steps; we know the total size of additional
      space required (added in d1deb12)
    - BytesMut can expand to usize::MAX now; so checking remaining_mut()
      only prevents a size overflow (can't allocate it anyway).
    - BytesMut::resize actually changes the size of the buffer and reduces
      `remaining_mut`
    - need to actually reserve enough space before taking
      `&mut buf.chunk_mut()[..msg_len];`
    stbuehler committed Jun 6, 2021
    Configuration menu
    Copy the full SHA
    48c212d View commit details
    Browse the repository at this point in the history
  3. netlink-proto: get rid of unsafe blocks in Encoder

    The only semantic difference: on unwind (panic in serialize) the buffer
    length already is the new one (but the contents were initialized to 0 anyway).
    stbuehler committed Jun 6, 2021
    Configuration menu
    Copy the full SHA
    88e09d8 View commit details
    Browse the repository at this point in the history