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.
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);
/* 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);
}
void
-buffer_reserve_headroom(struct buffer *b, size_t size)
+buffer_prealloc_headroom(struct buffer *b, size_t size)
{
assert(size <= buffer_headroom(b));
}
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;
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;
}
}
-/* 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.
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);
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) {