From 6edcc9e0e093c5d082ac76b1dcc73396897f5c24 Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Thu, 22 Dec 2011 15:12:05 -0800 Subject: [PATCH] Remove memcached_do() --- libmemcached/do.cc | 13 ------------- libmemcached/do.hpp | 5 ----- libmemcached/version.cc | 19 ++++++++++++++----- 3 files changed, 14 insertions(+), 23 deletions(-) diff --git a/libmemcached/do.cc b/libmemcached/do.cc index 88d8d843..ee777d3e 100644 --- a/libmemcached/do.cc +++ b/libmemcached/do.cc @@ -11,19 +11,6 @@ #include -memcached_return_t memcached_do(memcached_server_write_instance_st ptr, - const void *command, - const size_t command_length, - const bool with_flush) -{ - assert_msg(command_length, "Programming error, somehow a command had a length of zero"); - assert_msg(command, "Programming error, somehow a command was NULL"); - - libmemcached_io_vector_st vector[1]= { { command, command_length } }; - - return memcached_vdo(ptr, vector, 1, with_flush); -} - memcached_return_t memcached_vdo(memcached_server_write_instance_st ptr, const struct libmemcached_io_vector_st *vector, const size_t count, diff --git a/libmemcached/do.hpp b/libmemcached/do.hpp index 0bd0e9b3..aac94912 100644 --- a/libmemcached/do.hpp +++ b/libmemcached/do.hpp @@ -37,11 +37,6 @@ #pragma once -memcached_return_t memcached_do(memcached_server_write_instance_st ptr, - const void *commmand, - const size_t command_length, - const bool with_flush); - memcached_return_t memcached_vdo(memcached_server_write_instance_st ptr, const struct libmemcached_io_vector_st *vector, const size_t count, diff --git a/libmemcached/version.cc b/libmemcached/version.cc index b70cf672..4b9bfeeb 100644 --- a/libmemcached/version.cc +++ b/libmemcached/version.cc @@ -71,7 +71,12 @@ memcached_return_t memcached_version(memcached_st *ptr) static inline memcached_return_t memcached_version_textual(memcached_st *ptr) { + struct libmemcached_io_vector_st vector[]= + { + { memcached_literal_param("version\r\n") }, + }; memcached_return_t rc= MEMCACHED_SUCCESS; + for (uint32_t x= 0; x < memcached_server_count(ptr); x++) { memcached_server_write_instance_st instance= memcached_server_instance_fetch(ptr, x); @@ -82,7 +87,7 @@ static inline memcached_return_t memcached_version_textual(memcached_st *ptr) continue; } - memcached_return_t rrc= memcached_do(instance, memcached_literal_param("version\r\n"), true); + memcached_return_t rrc= memcached_vdo(instance, vector, 1, true); if (memcached_failed(rrc)) { (void)memcached_set_error(*instance, rrc, MEMCACHED_AT); @@ -92,7 +97,7 @@ static inline memcached_return_t memcached_version_textual(memcached_st *ptr) } char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; - rrc= memcached_response(instance, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL); + rrc= memcached_response(instance, buffer, sizeof(buffer), NULL); if (memcached_failed(rrc)) { memcached_set_error(*instance, rrc, MEMCACHED_AT); @@ -152,6 +157,11 @@ static inline memcached_return_t memcached_version_binary(memcached_st *ptr) request.message.header.request.opcode= PROTOCOL_BINARY_CMD_VERSION; request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES; + struct libmemcached_io_vector_st vector[]= + { + { request.bytes, sizeof(request.bytes) } + }; + memcached_return_t rc= MEMCACHED_SUCCESS; for (uint32_t x= 0; x < memcached_server_count(ptr); x++) { @@ -162,7 +172,7 @@ static inline memcached_return_t memcached_version_binary(memcached_st *ptr) continue; } - memcached_return_t rrc= memcached_do(instance, request.bytes, sizeof(request.bytes), true); + memcached_return_t rrc= memcached_vdo(instance, vector, 1, true); if (memcached_failed(rrc)) { memcached_io_reset(instance); @@ -173,8 +183,7 @@ static inline memcached_return_t memcached_version_binary(memcached_st *ptr) for (uint32_t x= 0; x < memcached_server_count(ptr); x++) { - memcached_server_write_instance_st instance= - memcached_server_instance_fetch(ptr, x); + memcached_server_write_instance_st instance= memcached_server_instance_fetch(ptr, x); if (instance->major_version != UINT8_MAX) { -- 2.30.2