From: Ben Pfaff Date: Mon, 14 Jul 2008 20:51:26 +0000 (-0700) Subject: buffer: Make buffer_pull() return the start of the pulled data. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d6ea83302af4676df036d3c7e52f680dd84cf9a6;p=openvswitch buffer: Make buffer_pull() return the start of the pulled data. Some callers find this useful. --- diff --git a/include/buffer.h b/include/buffer.h index 0d024ec9..c2cbb139 100644 --- a/include/buffer.h +++ b/include/buffer.h @@ -76,6 +76,6 @@ size_t buffer_tailroom(struct buffer *); void buffer_reserve_tailroom(struct buffer *, size_t); void buffer_clear(struct buffer *); -void buffer_pull(struct buffer *, size_t); +void *buffer_pull(struct buffer *, size_t); #endif /* buffer.h */ diff --git a/lib/buffer.c b/lib/buffer.c index 2b6e3b78..dc9887a9 100644 --- a/lib/buffer.c +++ b/lib/buffer.c @@ -231,12 +231,14 @@ buffer_clear(struct buffer *b) } /* Removes 'size' bytes from the head end of 'b', which must contain at least - * 'size' bytes of data. */ -void + * 'size' bytes of data. Returns the first byte of data removed. */ +void * buffer_pull(struct buffer *b, size_t size) { + void *data = b->data; assert(b->size >= size); b->data += size; b->size -= size; + return data; }