From: Brian Aker Date: Tue, 19 Jan 2010 00:55:33 +0000 (-0800) Subject: Fix inline methods for strings. X-Git-Tag: 0.40~85 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=a6d18834a85d2a65caae820ee426169af5aff800;p=awesomized%2Flibmemcached Fix inline methods for strings. --- 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,