X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fofpbuf.c;h=38874816c1f88679548bb1581b53547c42b5e7b1;hb=a281173e19918379832ec535b18aa2af58832efb;hp=8166d6b1c1a1f3ee29ed361fbae3afc9ef1690be;hpb=7ecb095d0bf4940406ce684c5c6d5c7adac4cf77;p=openvswitch diff --git a/lib/ofpbuf.c b/lib/ofpbuf.c index 8166d6b1..38874816 100644 --- a/lib/ofpbuf.c +++ b/lib/ofpbuf.c @@ -289,6 +289,16 @@ ofpbuf_trim(struct ofpbuf *b) } } +/* If 'b' is shorter than 'length' bytes, pads its tail out with zeros to that + * length. */ +void +ofpbuf_padto(struct ofpbuf *b, size_t length) +{ + if (b->size < length) { + ofpbuf_put_zeros(b, length - b->size); + } +} + /* Appends 'size' bytes of data to the tail end of 'b', reallocating and * copying its data if necessary. Returns a pointer to the first byte of the * new data, which is left uninitialized. */