+ result->key[result->key_length]= 0;
+ }
+
+ if (end_ptr == string_ptr)
+ goto read_error;
+
+ /* Flags fetch move past space */
+ string_ptr++;
+ if (end_ptr == string_ptr)
+ goto read_error;
+ for (next_ptr= string_ptr; isdigit(*string_ptr); string_ptr++);
+ result->flags= strtoul(next_ptr, &string_ptr, 10);
+
+ if (end_ptr == string_ptr)
+ goto read_error;
+
+ /* Length fetch move past space*/
+ string_ptr++;
+ if (end_ptr == string_ptr)
+ goto read_error;
+
+ for (next_ptr= string_ptr; isdigit(*string_ptr); string_ptr++);
+ value_length= (size_t)strtoull(next_ptr, &string_ptr, 10);
+
+ if (end_ptr == string_ptr)
+ goto read_error;
+
+ /* Skip spaces */
+ if (*string_ptr == '\r')
+ {
+ /* Skip past the \r\n */
+ string_ptr+= 2;
+ }
+ else
+ {
+ string_ptr++;
+ for (next_ptr= string_ptr; isdigit(*string_ptr); string_ptr++);
+ result->cas= strtoull(next_ptr, &string_ptr, 10);
+ }
+
+ if (end_ptr < string_ptr)
+ goto read_error;
+
+ /* We add two bytes so that we can walk the \r\n */
+ rc= memcached_string_check(&result->value, value_length+2);
+ if (rc != MEMCACHED_SUCCESS)
+ {
+ value_length= 0;
+ return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
+ }