version_textual no longer attempts to parse invalid response
[awesomized/libmemcached] / libmemcached / memcached_result.c
index cf3894bef3b7545fcdaca9be56d6e1883f25b2a3..8d376f680fd45ced6ef1cd6a88b4f3f21ed19666 100644 (file)
@@ -11,10 +11,7 @@ memcached_result_st *memcached_result_create(memcached_st *memc,
 {
   /* Saving malloc calls :) */
   if (ptr)
-  {
     memset(ptr, 0, sizeof(memcached_result_st));
-    ptr->is_allocated= MEMCACHED_NOT_ALLOCATED;
-  }
   else
   {
     if (memc->call_malloc)
@@ -25,17 +22,33 @@ memcached_result_st *memcached_result_create(memcached_st *memc,
     if (ptr == NULL)
       return NULL;
     memset(ptr, 0, sizeof(memcached_result_st));
-    ptr->is_allocated= MEMCACHED_ALLOCATED;
+    ptr->is_allocated= true;
   }
 
   ptr->root= memc;
   memcached_string_create(memc, &ptr->value, 0);
   WATCHPOINT_ASSERT(ptr->value.string == NULL);
-  WATCHPOINT_ASSERT(ptr->value.is_allocated == MEMCACHED_NOT_ALLOCATED);
 
   return ptr;
 }
 
+void memcached_result_reset(memcached_result_st *ptr)
+{
+  ptr->key_length= 0;
+  memcached_string_reset(&ptr->value);
+  ptr->flags= 0;
+  ptr->cas= 0;
+  ptr->expiration= 0;
+}
+
+/*
+  NOTE turn into macro
+*/
+memcached_return memcached_result_set_value(memcached_result_st *ptr, char *value, size_t length)
+{
+  return memcached_string_append(&ptr->value, value, length);
+}
+
 void memcached_result_free(memcached_result_st *ptr)
 {
   if (ptr == NULL)
@@ -43,8 +56,6 @@ void memcached_result_free(memcached_result_st *ptr)
 
   memcached_string_free(&ptr->value);
 
-  if (ptr->is_allocated == MEMCACHED_ALLOCATED)
+  if (ptr->is_allocated)
     free(ptr);
-  else
-    ptr->is_allocated= MEMCACHED_USED;
 }