attempt to fix #12, #49 and #65
[awesomized/libmemcached] / libmemcached / encoding_key.cc
index 3472029ce6c8a2cd1a228a6f3388ce4b29e21f9c..1e17d507a44b67b67756dcce0088d48283f17d43 100644 (file)
@@ -2,7 +2,7 @@
  * 
  *  Libmemcached library
  *
- *  Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ *  Copyright (C) 2011-2013 Data Differential, http://datadifferential.com/
  *  All rights reserved.
  *
  *  Redistribution and use in source and binary forms, with or without
 #include <libmemcached/common.h>
 #include <libmemcached/assert.hpp>
 
-static void _set_encoding_key(memcached_st& self, const char *key, size_t key_length)
+static void _set_encoding_key(Memcached& memc, const char *key, size_t key_length)
 {
-  hashkit_key(&self.hashkit, key, key_length);
+  hashkit_key(&memc.hashkit, key, key_length);
 }
 
-memcached_return_t memcached_set_encoding_key(memcached_st* self, const char *key, size_t key_length)
+memcached_return_t memcached_set_encoding_key(memcached_st* shell, const char *key, size_t key_length)
 {
-  if (self == NULL)
+  Memcached* memc= memcached2Memcached(shell);
+  if (memc)
   {
-    return MEMCACHED_INVALID_ARGUMENTS;
+    _set_encoding_key(*memc, key, key_length);
+    return MEMCACHED_SUCCESS;
   }
 
-  _set_encoding_key(*self, key, key_length);
-  return MEMCACHED_SUCCESS;
+  return MEMCACHED_INVALID_ARGUMENTS;
 }