From a6d18834a85d2a65caae820ee426169af5aff800 Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Mon, 18 Jan 2010 16:55:33 -0800 Subject: [PATCH] Fix inline methods for strings. --- libmemcached/response.c | 6 +++--- libmemcached/string.h | 23 ++++++++++++++++++++--- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/libmemcached/response.c b/libmemcached/response.c index cbb49784..3784438e 100644 --- a/libmemcached/response.c +++ b/libmemcached/response.c @@ -175,7 +175,7 @@ static memcached_return_t textual_value_fetch(memcached_server_instance_st *ptr, return MEMCACHED_MEMORY_ALLOCATION_FAILURE; } - value_ptr= memcached_string_value(&result->value); + value_ptr= memcached_string_value_mutable(&result->value); /* We read the \r\n into the string since not doing so is more cycles then the waster of memory to do so. @@ -196,7 +196,7 @@ static memcached_return_t textual_value_fetch(memcached_server_instance_st *ptr, /* This next bit blows the API, but this is internal....*/ { char *char_ptr; - char_ptr= memcached_string_value(&result->value);; + char_ptr= memcached_string_value_mutable(&result->value);; char_ptr[value_length]= 0; char_ptr[value_length + 1]= 0; memcached_string_set_length(&result->value, value_length); @@ -382,7 +382,7 @@ static memcached_return_t binary_read_one_response(memcached_server_instance_st bodylen) != MEMCACHED_SUCCESS) return MEMCACHED_MEMORY_ALLOCATION_FAILURE; - char *vptr= memcached_string_value(&result->value); + char *vptr= memcached_string_value_mutable(&result->value); if (memcached_safe_read(ptr, vptr, bodylen) != MEMCACHED_SUCCESS) return MEMCACHED_UNKNOWN_READ_FAILURE; diff --git a/libmemcached/string.h b/libmemcached/string.h index 188c6769..9e064d9a 100644 --- a/libmemcached/string.h +++ b/libmemcached/string.h @@ -37,10 +37,27 @@ struct memcached_string_st { } options; }; -#define memcached_string_length(A) (size_t)((A)->end - (A)->string) +static inline size_t memcached_string_length(const memcached_string_st *self) +{ + return (size_t)(self->end - self->string); +} + +static inline size_t memcached_string_size(const memcached_string_st *self) +{ + return self->current_size; +} + +static inline const char *memcached_string_value(const memcached_string_st *self) +{ + return self->string; +} + +static inline char *memcached_string_value_mutable(const memcached_string_st *self) +{ + return self->string; +} + #define memcached_string_set_length(A, B) (A)->end= (A)->string + B -#define memcached_string_size(A) (A)->current_size -#define memcached_string_value(A) (A)->string LIBMEMCACHED_LOCAL memcached_string_st *memcached_string_create(const memcached_st *ptr, -- 2.30.2