From f0436842355f85585aca30f53b365c08371e78c9 Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Tue, 29 Jan 2013 07:56:13 -0500 Subject: [PATCH] Clean up interfaces so that 1.2 is a bit easier to upgrade too. --- libmemcached/array.c | 6 +++--- libmemcached/array.h | 11 ++--------- libmemcached/auto.cc | 1 - libmemcached/error.cc | 24 ++++++++++++------------ libmemcached/error.hpp | 18 +++++++++--------- libmemcached/initialize_query.h | 4 ++-- 6 files changed, 28 insertions(+), 36 deletions(-) diff --git a/libmemcached/array.c b/libmemcached/array.c index 5f9066ce..cd472c39 100644 --- a/libmemcached/array.c +++ b/libmemcached/array.c @@ -41,13 +41,13 @@ struct memcached_array_st { - struct memcached_st *root; + Memcached *root; size_t size; char c_str[]; }; -memcached_array_st *memcached_array_clone(struct memcached_st *memc, const memcached_array_st *original) +memcached_array_st *memcached_array_clone(Memcached *memc, const memcached_array_st *original) { if (original) { @@ -57,7 +57,7 @@ memcached_array_st *memcached_array_clone(struct memcached_st *memc, const memca return NULL; } -memcached_array_st *memcached_strcpy(struct memcached_st *memc, const char *str, size_t str_length) +memcached_array_st *memcached_strcpy(Memcached *memc, const char *str, size_t str_length) { assert(memc); assert(str); diff --git a/libmemcached/array.h b/libmemcached/array.h index 0f6e8d0c..afb3f916 100644 --- a/libmemcached/array.h +++ b/libmemcached/array.h @@ -41,25 +41,18 @@ extern "C" { #endif -LIBMEMCACHED_LOCAL -memcached_array_st *memcached_array_clone(struct memcached_st *memc, const memcached_array_st *original); +memcached_array_st *memcached_array_clone(Memcached* memc, const memcached_array_st *original); -LIBMEMCACHED_LOCAL -memcached_array_st *memcached_strcpy(struct memcached_st *memc, const char *str, size_t str_length); +memcached_array_st *memcached_strcpy(Memcached* memc, const char *str, size_t str_length); -LIBMEMCACHED_LOCAL void memcached_array_free(memcached_array_st *array); -LIBMEMCACHED_LOCAL size_t memcached_array_size(memcached_array_st *array); -LIBMEMCACHED_LOCAL const char *memcached_array_string(memcached_array_st *array); -LIBMEMCACHED_LOCAL memcached_string_t memcached_array_to_string(memcached_array_st *array); -LIBMEMCACHED_LOCAL bool memcached_array_is_null(memcached_array_st *array); #ifdef __cplusplus diff --git a/libmemcached/auto.cc b/libmemcached/auto.cc index 57d6d2fd..85e2ae09 100644 --- a/libmemcached/auto.cc +++ b/libmemcached/auto.cc @@ -54,7 +54,6 @@ static void auto_response(org::libmemcached::Instance* instance, const bool repl if (memcached_fatal(rc)) { - fprintf(stderr, "%s\n", memcached_strerror(NULL, rc)); assert(memcached_last_error(instance->root) != MEMCACHED_SUCCESS); *value= UINT64_MAX; } diff --git a/libmemcached/error.cc b/libmemcached/error.cc index 314f3623..64aefa03 100644 --- a/libmemcached/error.cc +++ b/libmemcached/error.cc @@ -43,7 +43,7 @@ #define MAX_ERROR_LENGTH 2048 struct memcached_error_t { - memcached_st *root; + Memcached *root; uint64_t query_id; struct memcached_error_t *next; memcached_return_t rc; @@ -80,7 +80,7 @@ static void _set(org::libmemcached::Instance& server, Memcached& memc) static int error_log_fd= -1; #endif -static void _set(memcached_st& memc, memcached_string_t *str, memcached_return_t &rc, const char *at, int local_errno= 0) +static void _set(Memcached& memc, memcached_string_t *str, memcached_return_t &rc, const char *at, int local_errno= 0) { if (memc.error_messages && memc.error_messages->query_id != memc.query_id) { @@ -208,7 +208,7 @@ static void _set(memcached_st& memc, memcached_string_t *str, memcached_return_t #endif } -memcached_return_t memcached_set_error(memcached_st& memc, memcached_return_t rc, const char *at, const char *str, size_t length) +memcached_return_t memcached_set_error(Memcached& memc, memcached_return_t rc, const char *at, const char *str, size_t length) { assert_msg(rc != MEMCACHED_ERRNO, "Programmer error, MEMCACHED_ERRNO was set to be returned to client"); memcached_string_t tmp= { str, length }; @@ -228,7 +228,7 @@ memcached_return_t memcached_set_error(org::libmemcached::Instance& self, memcac #pragma GCC diagnostic ignored "-Wformat-nonliteral" #endif -memcached_return_t memcached_set_error(memcached_st& memc, memcached_return_t rc, const char *at, memcached_string_t& str) +memcached_return_t memcached_set_error(Memcached& memc, memcached_return_t rc, const char *at, memcached_string_t& str) { assert_msg(rc != MEMCACHED_ERRNO, "Programmer error, MEMCACHED_ERRNO was set to be returned to client"); if (memcached_fatal(rc) == false) @@ -241,7 +241,7 @@ memcached_return_t memcached_set_error(memcached_st& memc, memcached_return_t rc return rc; } -memcached_return_t memcached_set_parser_error(memcached_st& memc, +memcached_return_t memcached_set_parser_error(Memcached& memc, const char *at, const char *format, ...) { @@ -337,7 +337,7 @@ memcached_return_t memcached_set_error(org::libmemcached::Instance& self, memcac return rc; } -memcached_return_t memcached_set_error(memcached_st& self, memcached_return_t rc, const char *at) +memcached_return_t memcached_set_error(Memcached& self, memcached_return_t rc, const char *at) { assert_msg(rc != MEMCACHED_ERRNO, "Programmer error, MEMCACHED_ERRNO was set to be returned to client"); if (memcached_fatal(rc) == false) @@ -350,7 +350,7 @@ memcached_return_t memcached_set_error(memcached_st& self, memcached_return_t rc return rc; } -memcached_return_t memcached_set_errno(memcached_st& self, int local_errno, const char *at, const char *str, size_t length) +memcached_return_t memcached_set_errno(Memcached& self, int local_errno, const char *at, const char *str, size_t length) { memcached_string_t tmp= { str, length }; return memcached_set_errno(self, local_errno, at, tmp); @@ -362,7 +362,7 @@ memcached_return_t memcached_set_errno(org::libmemcached::Instance& self, int lo return memcached_set_errno(self, local_errno, at, tmp); } -memcached_return_t memcached_set_errno(memcached_st& self, int local_errno, const char *at) +memcached_return_t memcached_set_errno(Memcached& self, int local_errno, const char *at) { if (local_errno == 0) { @@ -375,7 +375,7 @@ memcached_return_t memcached_set_errno(memcached_st& self, int local_errno, cons return rc; } -memcached_return_t memcached_set_errno(memcached_st& memc, int local_errno, const char *at, memcached_string_t& str) +memcached_return_t memcached_set_errno(Memcached& memc, int local_errno, const char *at, memcached_string_t& str) { if (local_errno == 0) { @@ -470,7 +470,7 @@ static void _error_print(const memcached_error_t *error) _error_print(error->next); } -void memcached_error_print(const memcached_st *shell) +void memcached_error_print(const Memcached *shell) { const Memcached* self= memcached2Memcached(shell); if (self == NULL) @@ -498,7 +498,7 @@ static void _error_free(memcached_error_t *error) } } -void memcached_error_free(memcached_st& self) +void memcached_error_free(Memcached& self) { _error_free(self.error_messages); self.error_messages= NULL; @@ -542,7 +542,7 @@ const char *memcached_last_error_message(const memcached_st *shell) return memcached_strerror(memc, MEMCACHED_INVALID_ARGUMENTS); } -bool memcached_has_current_error(memcached_st &memc) +bool memcached_has_current_error(Memcached &memc) { if (memc.error_messages and memc.error_messages->query_id == memc.query_id diff --git a/libmemcached/error.hpp b/libmemcached/error.hpp index cdbc6ab1..733f7686 100644 --- a/libmemcached/error.hpp +++ b/libmemcached/error.hpp @@ -45,39 +45,39 @@ #define TOSTRING(x) STRINGIFY(x) #define MEMCACHED_AT __FILE__ ":" TOSTRING(__LINE__) -memcached_return_t memcached_set_parser_error(memcached_st& memc, +memcached_return_t memcached_set_parser_error(Memcached& memc, const char *at, const char *format, ...); -memcached_return_t memcached_set_error(memcached_st&, memcached_return_t rc, const char *at); +memcached_return_t memcached_set_error(Memcached&, memcached_return_t rc, const char *at); memcached_return_t memcached_set_error(org::libmemcached::Instance&, memcached_return_t rc, const char *at); -memcached_return_t memcached_set_error(memcached_st&, memcached_return_t rc, const char *at, const char *str, size_t length); +memcached_return_t memcached_set_error(Memcached&, memcached_return_t rc, const char *at, const char *str, size_t length); memcached_return_t memcached_set_error(org::libmemcached::Instance&, memcached_return_t rc, const char *at, const char *str, size_t length); -memcached_return_t memcached_set_error(memcached_st& memc, memcached_return_t rc, const char *at, memcached_string_t& str); +memcached_return_t memcached_set_error(Memcached& memc, memcached_return_t rc, const char *at, memcached_string_t& str); memcached_return_t memcached_set_error(org::libmemcached::Instance&, memcached_return_t rc, const char *at, memcached_string_t& str); -memcached_return_t memcached_set_errno(memcached_st& memc, int local_errno, const char *at, memcached_string_t& str); +memcached_return_t memcached_set_errno(Memcached& memc, int local_errno, const char *at, memcached_string_t& str); memcached_return_t memcached_set_errno(org::libmemcached::Instance&, int local_errno, const char *at, memcached_string_t& str); -memcached_return_t memcached_set_errno(memcached_st& memc, int local_errno, const char *at, const char *str, size_t length); +memcached_return_t memcached_set_errno(Memcached& memc, int local_errno, const char *at, const char *str, size_t length); memcached_return_t memcached_set_errno(org::libmemcached::Instance&, int local_errno, const char *at, const char *str, size_t length); -memcached_return_t memcached_set_errno(memcached_st& memc, int local_errno, const char *at); +memcached_return_t memcached_set_errno(Memcached& memc, int local_errno, const char *at); memcached_return_t memcached_set_errno(org::libmemcached::Instance&, int local_errno, const char *at); -bool memcached_has_current_error(memcached_st&); +bool memcached_has_current_error(Memcached&); bool memcached_has_current_error(org::libmemcached::Instance&); -void memcached_error_free(memcached_st&); +void memcached_error_free(Memcached&); void memcached_error_free(memcached_server_st&); diff --git a/libmemcached/initialize_query.h b/libmemcached/initialize_query.h index 943a37a3..105283c0 100644 --- a/libmemcached/initialize_query.h +++ b/libmemcached/initialize_query.h @@ -36,6 +36,6 @@ #pragma once -memcached_return_t initialize_query(memcached_st *self, bool increment_query_id); +memcached_return_t initialize_query(Memcached *self, bool increment_query_id); -memcached_return_t initialize_const_query(const memcached_st *self); +memcached_return_t initialize_const_query(const Memcached *self); -- 2.30.2