From: Ben Pfaff Date: Mon, 14 Jul 2008 20:51:37 +0000 (-0700) Subject: buffer: Rename buffer_reserve_headroom to buffer_prealloc_headroom. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=86ad61454e800a5c9116f44cd9f4fd549e49bc5f;p=openvswitch buffer: Rename buffer_reserve_headroom to buffer_prealloc_headroom. Similarly for buffer_reserve_tailroom. The new name better reflects what they do, and make way for a different use of the term "reserve" in the upcoming buffer_reserve() function. --- diff --git a/include/buffer.h b/include/buffer.h index c2cbb139..16183f6e 100644 --- a/include/buffer.h +++ b/include/buffer.h @@ -73,7 +73,8 @@ void *buffer_push_uninit(struct buffer *b, size_t); size_t buffer_headroom(struct buffer *); size_t buffer_tailroom(struct buffer *); -void buffer_reserve_tailroom(struct buffer *, size_t); +void buffer_prealloc_headroom(struct buffer *, size_t); +void buffer_prealloc_tailroom(struct buffer *, size_t); void buffer_clear(struct buffer *); void *buffer_pull(struct buffer *, size_t); diff --git a/lib/buffer.c b/lib/buffer.c index dc9887a9..8604913f 100644 --- a/lib/buffer.c +++ b/lib/buffer.c @@ -128,7 +128,7 @@ buffer_tailroom(struct buffer *b) /* Ensures that 'b' has room for at least 'size' bytes at its tail end, * reallocating and copying its data if necessary. */ void -buffer_reserve_tailroom(struct buffer *b, size_t size) +buffer_prealloc_tailroom(struct buffer *b, size_t size) { if (size > buffer_tailroom(b)) { size_t new_allocated = b->allocated + MAX(size, 64); @@ -152,7 +152,7 @@ buffer_reserve_tailroom(struct buffer *b, size_t size) } void -buffer_reserve_headroom(struct buffer *b, size_t size) +buffer_prealloc_headroom(struct buffer *b, size_t size) { assert(size <= buffer_headroom(b)); } @@ -164,7 +164,7 @@ void * buffer_put_uninit(struct buffer *b, size_t size) { void *p; - buffer_reserve_tailroom(b, size); + buffer_prealloc_tailroom(b, size); p = buffer_tail(b); b->size += size; return p; @@ -184,7 +184,7 @@ buffer_put(struct buffer *b, const void *p, size_t size) void * buffer_push_uninit(struct buffer *b, size_t size) { - buffer_reserve_headroom(b, size); + buffer_prealloc_headroom(b, size); b->data -= size; b->size += size; return b->data; diff --git a/lib/netlink.c b/lib/netlink.c index 04807883..2d63ceba 100644 --- a/lib/netlink.c +++ b/lib/netlink.c @@ -470,12 +470,12 @@ nl_msg_nlmsgerr(const struct buffer *msg, int *errorp) } } -/* Ensures that 'b' has room for at least 'size' bytes plus netlink pading at +/* Ensures that 'b' has room for at least 'size' bytes plus netlink padding at * its tail end, reallocating and copying its data if necessary. */ void nl_msg_reserve(struct buffer *msg, size_t size) { - buffer_reserve_tailroom(msg, NLMSG_ALIGN(size)); + buffer_prealloc_tailroom(msg, NLMSG_ALIGN(size)); } /* Puts a nlmsghdr at the beginning of 'msg', which must be initially empty. diff --git a/lib/vconn-ssl.c b/lib/vconn-ssl.c index 922f8a86..607d9b9e 100644 --- a/lib/vconn-ssl.c +++ b/lib/vconn-ssl.c @@ -458,7 +458,7 @@ again: return 0; } } - buffer_reserve_tailroom(rx, want_bytes); + buffer_prealloc_tailroom(rx, want_bytes); /* Behavior of zero-byte SSL_read is poorly defined. */ assert(want_bytes > 0); diff --git a/lib/vconn-tcp.c b/lib/vconn-tcp.c index 50304d33..aaff9403 100644 --- a/lib/vconn-tcp.c +++ b/lib/vconn-tcp.c @@ -200,7 +200,7 @@ again: return 0; } } - buffer_reserve_tailroom(rx, want_bytes); + buffer_prealloc_tailroom(rx, want_bytes); retval = read(tcp->fd, buffer_tail(rx), want_bytes); if (retval > 0) {