memcached_return_t *error)
{
memcached_return_t unused;
- if (not error)
+ if (error == NULL)
+ {
error= &unused;
+ }
- if (not ptr)
+ if (ptr == NULL)
{
*error= MEMCACHED_INVALID_ARGUMENTS;
return NULL;
// create one.
if (memcached_is_initialized(&ptr->result))
{
- if (not (result= memcached_result_create(ptr, NULL)))
+ if ((result= memcached_result_create(ptr, NULL)) == NULL)
{
*error= MEMCACHED_MEMORY_ALLOCATION_FAILURE;
return NULL;
{
if (ptr->get_key_failure and *error == MEMCACHED_NOTFOUND)
{
- memcached_result_reset(&ptr->result);
- memcached_return_t rc= ptr->get_key_failure(ptr, key, key_length, &ptr->result);
+ memcached_result_st key_failure_result;
+ memcached_result_st* result_ptr= memcached_result_create(ptr, &key_failure_result);
+ memcached_return_t rc= ptr->get_key_failure(ptr, key, key_length, result_ptr);
/* On all failure drop to returning NULL */
if (rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED)
}
rc= memcached_set(ptr, key, key_length,
- (memcached_result_value(&ptr->result)),
- (memcached_result_length(&ptr->result)),
+ (memcached_result_value(result_ptr)),
+ (memcached_result_length(result_ptr)),
0,
- (memcached_result_flags(&ptr->result)));
+ (memcached_result_flags(result_ptr)));
if (rc == MEMCACHED_BUFFERED and latch == 0)
{
else
{
rc= memcached_set(ptr, key, key_length,
- (memcached_result_value(&ptr->result)),
- (memcached_result_length(&ptr->result)),
+ (memcached_result_value(result_ptr)),
+ (memcached_result_length(result_ptr)),
0,
- (memcached_result_flags(&ptr->result)));
+ (memcached_result_flags(result_ptr)));
}
if (rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED)
{
*error= rc;
- *value_length= memcached_result_length(&ptr->result);
- *flags= memcached_result_flags(&ptr->result);
- return memcached_string_take_value(&ptr->result.value);
+ *value_length= memcached_result_length(result_ptr);
+ *flags= memcached_result_flags(result_ptr);
+ char *result_value= memcached_string_take_value(&result_ptr->value);
+ memcached_result_free(result_ptr);
+
+ return result_value;
}
}
+
+ memcached_result_free(result_ptr);
}
assert_msg(ptr->query_id == query_id +1, "Programmer error, the query_id was not incremented.");
}
#define READ_THROUGH_VALUE "set for me"
-static memcached_return_t read_through_trigger(memcached_st *memc,
- char *key,
- size_t key_length,
+static memcached_return_t read_through_trigger(memcached_st *, // memc
+ char *, // key
+ size_t, // key_length,
memcached_result_st *result)
{
- (void)memc;(void)key;(void)key_length;
return memcached_result_set_value(result, READ_THROUGH_VALUE, strlen(READ_THROUGH_VALUE));
}
&string_length, &flags, &rc);
test_compare(MEMCACHED_SUCCESS, rc);
- test_compare(string_length, sizeof(READ_THROUGH_VALUE) -1);
- test_true(string[sizeof(READ_THROUGH_VALUE) -1] == 0);
+ test_compare(sizeof(READ_THROUGH_VALUE) -1, string_length);
+ test_compare(0, string[sizeof(READ_THROUGH_VALUE) -1]);
test_strcmp(READ_THROUGH_VALUE, string);
free(string);