From 66ad587f2f9e9d9ce44437c1e185a961cfc13290 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Sun, 8 Feb 2015 19:10:49 +0000 Subject: [PATCH 21/29] [buffer] constify some parameters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Stefan Bühler git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2981 152afb58-edef-0310-8abb-c4023f1b3aa9 --- src/buffer.c | 12 ++++++------ src/buffer.h | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/buffer.c b/src/buffer.c index 425d700..57c1613 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -409,11 +409,11 @@ char * buffer_search_string_len(buffer *b, const char *needle, size_t len) { return NULL; } -int buffer_is_empty(buffer *b) { +int buffer_is_empty(const buffer *b) { return NULL == b || 0 == b->used; } -int buffer_string_is_empty(buffer *b) { +int buffer_string_is_empty(const buffer *b) { return 0 == buffer_string_length(b); } @@ -424,7 +424,7 @@ int buffer_string_is_empty(buffer *b) { * alignment properly. */ -int buffer_is_equal(buffer *a, buffer *b) { +int buffer_is_equal(const buffer *a, const buffer *b) { force_assert(NULL != a && NULL != b); if (a->used != b->used) return 0; @@ -433,7 +433,7 @@ int buffer_is_equal(buffer *a, buffer *b) { return (0 == memcmp(a->ptr, b->ptr, a->used)); } -int buffer_is_equal_string(buffer *a, const char *s, size_t b_len) { +int buffer_is_equal_string(const buffer *a, const char *s, size_t b_len) { force_assert(NULL != a && NULL != s); force_assert(b_len + 1 > b_len); @@ -445,7 +445,7 @@ int buffer_is_equal_string(buffer *a, const char *s, size_t b_len) { } /* buffer_is_equal_caseless_string(b, CONST_STR_LEN("value")) */ -int buffer_is_equal_caseless_string(buffer *a, const char *s, size_t b_len) { +int buffer_is_equal_caseless_string(const buffer *a, const char *s, size_t b_len) { force_assert(NULL != a); if (a->used != b_len + 1) return 0; force_assert('\0' == a->ptr[a->used - 1]); @@ -472,7 +472,7 @@ int buffer_caseless_compare(const char *a, size_t a_len, const char *b, size_t b return a_len < b_len ? -1 : 1; } -int buffer_is_equal_right_len(buffer *b1, buffer *b2, size_t len) { +int buffer_is_equal_right_len(const buffer *b1, const buffer *b2, size_t len) { /* no len -> equal */ if (len == 0) return 1; diff --git a/src/buffer.h b/src/buffer.h index f5d0224..b6065d4 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -112,14 +112,14 @@ char * buffer_search_string_len(buffer *b, const char *needle, size_t len); * unset "string" (buffer) config options are initialized to used == 0, * while setting an empty string leads to used == 1 */ -int buffer_is_empty(buffer *b); +int buffer_is_empty(const buffer *b); /* NULL buffer, empty buffer (used == 0) or empty string (used == 1) */ -int buffer_string_is_empty(buffer *b); +int buffer_string_is_empty(const buffer *b); -int buffer_is_equal(buffer *a, buffer *b); -int buffer_is_equal_right_len(buffer *a, buffer *b, size_t len); -int buffer_is_equal_string(buffer *a, const char *s, size_t b_len); -int buffer_is_equal_caseless_string(buffer *a, const char *s, size_t b_len); +int buffer_is_equal(const buffer *a, const buffer *b); +int buffer_is_equal_right_len(const buffer *a, const buffer *b, size_t len); +int buffer_is_equal_string(const buffer *a, const char *s, size_t b_len); +int buffer_is_equal_caseless_string(const buffer *a, const char *s, size_t b_len); int buffer_caseless_compare(const char *a, size_t a_len, const char *b, size_t b_len); typedef enum { -- 2.4.5