/* Saving malloc calls :) */
if (string)
- {
memset(string, 0, sizeof(memcached_string_st));
- string->is_allocated= MEMCACHED_NOT_ALLOCATED;
- }
else
{
if (ptr->call_malloc)
if (string == NULL)
return NULL;
memset(string, 0, sizeof(memcached_string_st));
- string->is_allocated= MEMCACHED_ALLOCATED;
+ string->is_allocated= true;
}
string->block_size= MEMCACHED_BLOCK_SIZE;
string->root= ptr;
{
memcached_return rc;
- WATCHPOINT_ASSERT(string->is_allocated != MEMCACHED_USED);
-
rc= memcached_string_check(string, 1);
if (rc != MEMCACHED_SUCCESS)
return rc;
- *string->end= ' ';
+ *string->end= character;
string->end++;
return MEMCACHED_SUCCESS;
{
memcached_return rc;
- WATCHPOINT_ASSERT(string->is_allocated != MEMCACHED_USED);
-
rc= memcached_string_check(string, length);
if (rc != MEMCACHED_SUCCESS)
return MEMCACHED_SUCCESS;
}
-size_t memcached_string_backspace(memcached_string_st *string, size_t remove)
-{
- WATCHPOINT_ASSERT(string->is_allocated != MEMCACHED_USED);
-
- if (string->end - string->string > remove)
- {
- size_t difference;
-
- difference= string->end - string->string;
- string->end= string->string;
-
- return difference;
- }
- string->end-= remove;
-
- return remove;
-}
-
char *memcached_string_c_copy(memcached_string_st *string)
{
char *c_ptr;
- WATCHPOINT_ASSERT(string->is_allocated != MEMCACHED_USED);
-
if (memcached_string_length(string) == 0)
return NULL;
memcached_return memcached_string_reset(memcached_string_st *string)
{
- WATCHPOINT_ASSERT(string->is_allocated != MEMCACHED_USED);
string->end= string->string;
return MEMCACHED_SUCCESS;
free(ptr->string);
}
- if (ptr->is_allocated == MEMCACHED_ALLOCATED)
+ if (ptr->is_allocated)
{
if (ptr->root->call_free)
ptr->root->call_free(ptr->root, ptr);
free(ptr);
}
else
- ptr->is_allocated= MEMCACHED_USED;
+ memset(ptr, 0, sizeof(memcached_string_st));
}