X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fresponse.cc;h=1548b4ed23c847f1ad2a6f70d4680809803b959a;hb=e4e6bde654ddb9017f090f3a36d6e9f5fd70b354;hp=44ce840ab722fa32e99f3ea4093c05fd9531fd56;hpb=d8dedbd561c7cb57daf4192fe57ce5e205bcadd7;p=m6w6%2Flibmemcached diff --git a/libmemcached/response.cc b/libmemcached/response.cc index 44ce840a..1548b4ed 100644 --- a/libmemcached/response.cc +++ b/libmemcached/response.cc @@ -142,7 +142,7 @@ static memcached_return_t textual_value_fetch(memcached_server_write_instance_st key= result->item_key; result->key_length= 0; - for (prefix_length= memcached_array_size(ptr->root->prefix_key); !(iscntrl(*string_ptr) || isspace(*string_ptr)) ; string_ptr++) + for (prefix_length= memcached_array_size(ptr->root->_namespace); !(iscntrl(*string_ptr) || isspace(*string_ptr)) ; string_ptr++) { if (prefix_length == 0) { @@ -218,7 +218,7 @@ static memcached_return_t textual_value_fetch(memcached_server_write_instance_st if (memcached_failed(rrc) and rrc == MEMCACHED_IN_PROGRESS) { memcached_quit_server(ptr, true); - return memcached_set_error(*ptr, rrc, MEMCACHED_AT); + return memcached_set_error(*ptr, MEMCACHED_IN_PROGRESS, MEMCACHED_AT); } else if (memcached_failed(rrc)) { @@ -291,28 +291,7 @@ static memcached_return_t textual_read_one_response(memcached_server_write_insta while (*endptr != '\r' && *endptr != '\n') endptr++; - /* - Yes, we could make this "efficent" but to do that we would need - to maintain more state for the size of the buffer. Why waste - memory in the struct, which is important, for something that - rarely should happen? - */ - char *rel_ptr= (char *)libmemcached_realloc(ptr->root, - ptr->cached_server_error, - (size_t) (endptr - startptr + 1)); - - if (rel_ptr == NULL) - { - /* If we happened to have some memory, we just null it since we don't know the size */ - if (ptr->cached_server_error) - ptr->cached_server_error[0]= 0; - return MEMCACHED_SERVER_ERROR; - } - ptr->cached_server_error= rel_ptr; - - memcpy(ptr->cached_server_error, startptr, (size_t) (endptr - startptr)); - ptr->cached_server_error[endptr - startptr]= 0; - return MEMCACHED_SERVER_ERROR; + return memcached_set_error(*ptr, MEMCACHED_SERVER_ERROR, MEMCACHED_AT, startptr, size_t(endptr - startptr)); } else if (buffer[1] == 'T') { @@ -439,15 +418,15 @@ static memcached_return_t binary_read_one_response(memcached_server_write_instan // Only bother with doing this if key_length > 0 if (result->key_length) { - if (memcached_array_size(ptr->root->prefix_key) and memcached_array_size(ptr->root->prefix_key) >= result->key_length) + if (memcached_array_size(ptr->root->_namespace) and memcached_array_size(ptr->root->_namespace) >= result->key_length) { return memcached_set_error(*ptr, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT); } - if (memcached_array_size(ptr->root->prefix_key)) + if (memcached_array_size(ptr->root->_namespace)) { - result->key_length-= memcached_array_size(ptr->root->prefix_key); - memmove(result->item_key, result->item_key +memcached_array_size(ptr->root->prefix_key), result->key_length); + result->key_length-= memcached_array_size(ptr->root->_namespace); + memmove(result->item_key, result->item_key +memcached_array_size(ptr->root->_namespace), result->key_length); } }