From: Helmut Grohne <helmut@subdivi.de>
Subject: support copy method of haslib objects
Last-Modified: 2014-09-28

Index: python-ssdeep-3.1/ssdeep/__init__.py
===================================================================
--- python-ssdeep-3.1.orig/ssdeep/__init__.py	2014-08-07 21:31:22.000000000 +0200
+++ python-ssdeep-3.1/ssdeep/__init__.py	2014-09-28 15:29:37.000000000 +0200
@@ -44,6 +44,18 @@
         if self._state == ffi.NULL:
             raise InternalError("Unable to create state object")
 
+    def copy(self):
+        """Create a copy of this hash object.
+
+        :raises InternalError: If the lib returns an internal error
+        """
+        newstate = binding.lib.fuzzy_clone(self._state)
+        if newstate == ffi.NULL:
+            raise InternalError("cloning of fuzzy state object failed")
+        new = Hash.__new__(Hash)
+        new._state = newstate
+        return new
+
     def update(self, buf, encoding="utf-8"):
         """
          Feed the data contained in the given buffer to the state.
Index: python-ssdeep-3.1/ssdeep/binding.py
===================================================================
--- python-ssdeep-3.1.orig/ssdeep/binding.py	2014-08-07 21:31:22.000000000 +0200
+++ python-ssdeep-3.1/ssdeep/binding.py	2014-09-28 14:36:35.000000000 +0200
@@ -11,6 +11,8 @@
 
     struct fuzzy_state;
     struct fuzzy_state *fuzzy_new(void);
+    struct fuzzy_state *fuzzy_clone(
+        const struct fuzzy_state *);
     int fuzzy_update(
         struct fuzzy_state *,
         const unsigned char *,
@@ -62,6 +64,7 @@
     struct fuzzy_state {};
     const long FUZZY_FLAG_ELIMSEQ = 0;
     const long FUZZY_FLAG_NOTRUNC = 0;
+    int (*fuzzy_clone)(const struct fuzzy_state *) = NULL;
     int (*fuzzy_digest)(
         const struct fuzzy_state *,
         char *,
@@ -91,6 +94,7 @@
     "ssdeep_HAS_STATEFUL_HASHING": (
         "FUZZY_FLAG_ELIMSEQ",
         "FUZZY_FLAG_NOTRUNC",
+        "fuzzy_clone",
         "fuzzy_digest",
         "fuzzy_free",
         "fuzzy_new",
