Adding test, showing off how to add a custom function to libmemcached.
[m6w6/libmemcached] / libhashkit / hashkit.h
index 8b7985ac6050cd6b2684af82f51adcc0a101dd68..bab3bc08d1f2ba7e8d7df4c8d3c06cf3748175fb 100644 (file)
@@ -63,35 +63,32 @@ struct hashkit_st
   struct {
     bool is_allocated:1;
   } options;
+};
 
 #ifdef __cplusplus
+class Hashkit : private hashkit_st {
+
+public:
 
-  hashkit_st() :
-    base_hash(),
-    distribution_hash(),
-    flags(),
-    options()
+  Hashkit()
   {
     hashkit_create(this);
   }
 
-  hashkit_st(const hashkit_st& source) :
-    base_hash(),
-    distribution_hash(),
-    flags(),
-    options()
+  Hashkit(const Hashkit& source)
   {
     hashkit_clone(this, &source);
   }
 
-  hashkit_st& operator=(const hashkit_st& source)
+  Hashkit& operator=(const Hashkit& source)
   { 
+    hashkit_free(this);
     hashkit_clone(this, &source);
 
     return *this;
   }
 
-  friend bool operator==(const hashkit_st &left, const hashkit_st &right)
+  friend bool operator==(const Hashkit &left, const Hashkit &right)
   {
     return hashkit_compare(&left, &right);
   }
@@ -116,12 +113,12 @@ struct hashkit_st
     return hashkit_set_function(this, hash_algorithm);
   }
 
-  ~hashkit_st()
+  ~Hashkit()
   {
     hashkit_free(this);
   }
-#endif
 };
+#endif
 
 
 #endif /* HASHKIT_H */