2 * Copyright (C) 2006-2009 Brian Aker
5 * Use and distribution licensed under the BSD license. See
6 * the COPYING file in the parent directory for full text.
8 * Summary: Functions to manipulate the result structure.
13 memcached_result_st are used to internally represent the return values from
14 memcached. We use a structure so that long term as identifiers are added
15 to memcached we will be able to absorb new attributes without having
16 to addjust the entire API.
20 memcached_result_st
*memcached_result_create(memcached_st
*memc
,
21 memcached_result_st
*ptr
)
23 WATCHPOINT_ASSERT(memc
);
24 WATCHPOINT_ASSERT(memc
->options
.is_initialized
);
26 /* Saving malloc calls :) */
29 memset(ptr
, 0, sizeof(memcached_result_st
));
33 ptr
= memc
->call_calloc(memc
, 1, sizeof(memcached_result_st
));
37 ptr
->options
.is_allocated
= true;
40 ptr
->options
.is_initialized
= true;
43 memcached_string_create(memc
, &ptr
->value
, 0);
44 WATCHPOINT_ASSERT_INITIALIZED(&ptr
->value
);
45 WATCHPOINT_ASSERT(ptr
->value
.string
== NULL
);
50 void memcached_result_reset(memcached_result_st
*ptr
)
53 memcached_string_reset(&ptr
->value
);
59 void memcached_result_free(memcached_result_st
*ptr
)
64 memcached_string_free(&ptr
->value
);
66 if (memcached_is_allocated(ptr
))
68 if (ptr
->root
!= NULL
)
70 ptr
->root
->call_free(ptr
->root
, ptr
);
79 ptr
->options
.is_initialized
= false;