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; }
memcached_result_st *memcached_fetch_result(memcached_st *ptr, memcached_result_st *result, memcached_return *error) { if (result == NULL) result= memcached_result_create(ptr, NULL); #ifdef UNUSED if (ptr->flags & MEM_NO_BLOCK) memcached_io_preread(ptr); #endif while (ptr->cursor_server < ptr->number_of_hosts) { char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; if (memcached_server_response_count(&ptr->hosts[ptr->cursor_server]) == 0) { ptr->cursor_server++; continue; } *error= memcached_response(&ptr->hosts[ptr->cursor_server], buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, result); if (*error == MEMCACHED_END) /* END means that we move on to the next */ { memcached_server_response_reset(&ptr->hosts[ptr->cursor_server]); ptr->cursor_server++; continue; } else if (*error == MEMCACHED_SUCCESS) return result; else return NULL; } /* We have completed reading data */ if (result->is_allocated) memcached_result_free(result); else memcached_string_reset(&result->value); ptr->cursor_server= 0; return NULL; }