{
if (need && need > (size_t)(string->current_size - (size_t)(string->end - string->string)))
{
- size_t current_offset= string->end - string->string;
+ size_t current_offset= (size_t) (string->end - string->string);
char *new_value;
size_t adjust;
size_t new_size;
if (new_size < need)
return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
- if (string->root->call_realloc)
- new_value= (char *)string->root->call_realloc(string->root, string->string, new_size);
- else
- new_value= (char *)realloc(string->string, new_size);
+ new_value= string->root->call_realloc(string->root, string->string, new_size);
if (new_value == NULL)
return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
memset(string, 0, sizeof(memcached_string_st));
else
{
- if (ptr->call_malloc)
- string= (memcached_string_st *)ptr->call_malloc(ptr, sizeof(memcached_string_st));
- else
- string= (memcached_string_st *)calloc(1, sizeof(memcached_string_st));
+ string= ptr->call_calloc(ptr, 1, sizeof(memcached_string_st));
if (string == NULL)
return NULL;
rc= memcached_string_check(string, initial_size);
if (rc != MEMCACHED_SUCCESS)
{
- if (ptr->call_free)
- ptr->call_free(ptr, string);
- else
- free(string);
-
+ ptr->call_free(ptr, string);
return NULL;
}
}
memcached_return memcached_string_append(memcached_string_st *string,
- char *value, size_t length)
+ const char *value, size_t length)
{
memcached_return rc;
if (memcached_string_length(string) == 0)
return NULL;
- if (string->root->call_malloc)
- c_ptr= (char *)string->root->call_malloc(string->root, (memcached_string_length(string)+1) * sizeof(char));
- else
- c_ptr= (char *)malloc((memcached_string_length(string)+1) * sizeof(char));
+ c_ptr= string->root->call_malloc(string->root, (memcached_string_length(string)+1) * sizeof(char));
if (c_ptr == NULL)
return NULL;
return;
if (ptr->string)
- {
- if (ptr->root->call_free)
- ptr->root->call_free(ptr->root, ptr->string);
- else
- free(ptr->string);
- }
+ ptr->root->call_free(ptr->root, ptr->string);
if (ptr->is_allocated)
- {
- if (ptr->root->call_free)
- ptr->root->call_free(ptr->root, ptr);
- else
- free(ptr);
- }
+ ptr->root->call_free(ptr->root, ptr);
else
memset(ptr, 0, sizeof(memcached_string_st));
}