From 6642bdf9cd779471fbc0a843f3d1450541eb46be Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C5=99emysl=20Janouch?=
Date: Mon, 23 Jan 2017 23:05:42 +0100
Subject: [PATCH] Rename str_ensure_space() to str_reserve()
Let's not invent our own terminology.
---
liberty.c | 8 ++++----
tests/liberty.c | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/liberty.c b/liberty.c
index 78e6ffe..6976aca 100644
--- a/liberty.c
+++ b/liberty.c
@@ -516,7 +516,7 @@ str_steal (struct str *self)
}
static void
-str_ensure_space (struct str *self, size_t n)
+str_reserve (struct str *self, size_t n)
{
// We allocate at least one more byte for the terminating null character
size_t new_alloc = self->alloc;
@@ -529,7 +529,7 @@ str_ensure_space (struct str *self, size_t n)
static void
str_append_data (struct str *self, const void *data, size_t n)
{
- str_ensure_space (self, n);
+ str_reserve (self, n);
memcpy (self->str + self->len, data, n);
self->len += n;
self->str[self->len] = '\0';
@@ -567,7 +567,7 @@ str_append_vprintf (struct str *self, const char *fmt, va_list va)
return -1;
va_copy (ap, va);
- str_ensure_space (self, size);
+ str_reserve (self, size);
size = vsnprintf (self->str + self->len, self->alloc - self->len, fmt, ap);
va_end (ap);
@@ -4333,7 +4333,7 @@ socket_io_try_read (int socket_fd, struct str *rb)
ssize_t n_read;
while (rb->len < read_limit)
{
- str_ensure_space (rb, 1024);
+ str_reserve (rb, 1024);
n_read = recv (socket_fd, rb->str + rb->len,
rb->alloc - rb->len - 1 /* null byte */, 0);
diff --git a/tests/liberty.c b/tests/liberty.c
index b46ef87..ae66fc8 100644
--- a/tests/liberty.c
+++ b/tests/liberty.c
@@ -199,7 +199,7 @@ test_str (void)
struct str s;
str_init (&s);
- str_ensure_space (&s, MEGA);
+ str_reserve (&s, MEGA);
str_append_data (&s, x, sizeof x);
str_remove_slice (&s, 4, 4);
soft_assert (s.len == 4);