From 258dd2a53afad021c342efde0a6b43b055b5602b Mon Sep 17 00:00:00 2001 From: Padraig O'Sullivan Date: Sat, 19 Sep 2009 19:36:57 -0400 Subject: [PATCH] Used std::string instead of char and sprintf for constructing an error message. --- libmemcached/memcached.hpp | 5 ++--- tests/cpp_example.cc | 8 ++++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/libmemcached/memcached.hpp b/libmemcached/memcached.hpp index bb8a9732..c42eba03 100644 --- a/libmemcached/memcached.hpp +++ b/libmemcached/memcached.hpp @@ -446,9 +446,8 @@ public: retval= set(it->first, it->second, expiration, flags); if (retval == false) { - char err_buff[64]; - sprintf(err_buff, "There was an error setting the key %s", - it->first.c_str()); + std::string err_buff("There was an error setting the key "); + err_buff.append(it->first); throw(Error(err_buff, false)); } ++it; diff --git a/tests/cpp_example.cc b/tests/cpp_example.cc index 5454f020..b96aaf4e 100644 --- a/tests/cpp_example.cc +++ b/tests/cpp_example.cc @@ -167,6 +167,7 @@ void setProduct(const string &key, const Product &product) int main() { +#if 0 Product pad(1, 5.0); const string key("padraig"); cout << "Going to set an object in the cache..." << endl; @@ -190,5 +191,12 @@ int main() cout << "product " << (*iter).getId() << " costs " << (*iter).getPrice() << endl; ++iter; } +#endif + Memcache first_client("127.0.0.1:11211"); + Memcache second_client("127.0.0.1", 11211); + //first_client.set("key", some_vector_of_chars, expiry, flags); + //first_client.get("key", vector_to_fill_with_data); + //first_client.remove("key"); + first_client.addServer("192.168.1.1", 11211); return 0; } -- 2.30.2