diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2017-01-23 23:05:42 +0100 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2017-01-23 23:05:42 +0100 |
commit | 6642bdf9cd779471fbc0a843f3d1450541eb46be (patch) | |
tree | becd2b7cf9432844b01d505ef2e2f8a251b365e3 | |
parent | 349a0fc3b123e1dc073628ccc0219a4b8bd1f84f (diff) | |
download | liberty-6642bdf9cd779471fbc0a843f3d1450541eb46be.tar.gz liberty-6642bdf9cd779471fbc0a843f3d1450541eb46be.tar.xz liberty-6642bdf9cd779471fbc0a843f3d1450541eb46be.zip |
Rename str_ensure_space() to str_reserve()
Let's not invent our own terminology.
-rw-r--r-- | liberty.c | 8 | ||||
-rw-r--r-- | tests/liberty.c | 2 |
2 files changed, 5 insertions, 5 deletions
@@ -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); |