Add helper to truncate the buffer to certain size which might be useful if some earlier part of the buffer can be reused multiple times without copying the whole buffer.
Signed-off-by: Ales Musil <[email protected]> --- include/openvswitch/ofpbuf.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/openvswitch/ofpbuf.h b/include/openvswitch/ofpbuf.h index 1fc4a3a7f..bac574548 100644 --- a/include/openvswitch/ofpbuf.h +++ b/include/openvswitch/ofpbuf.h @@ -292,6 +292,13 @@ static inline bool ofpbuf_oversized(const struct ofpbuf *ofpacts) return (char *)ofpbuf_tail(ofpacts) - (char *)ofpacts->header > UINT16_MAX; } +static inline void ofpbuf_truncate(struct ofpbuf *b, size_t size) +{ + ovs_assert(b->size >= size); + b->data = (uint8_t *) b->data - size; + b->size = b->size - size; +} + #ifdef __cplusplus } #endif -- 2.47.0 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
