This change eliminates a potential memory leak and it
fixes a mem check bug that was blocking the skia roll 
into Chromium.

BUG=http://code.google.com/p/skia/issues/detail?id=278




git-svn-id: http://skia.googlecode.com/svn/trunk@1424 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/src/GrBinHashKey.h b/gpu/src/GrBinHashKey.h
index 683528b..a270cc2 100644
--- a/gpu/src/GrBinHashKey.h
+++ b/gpu/src/GrBinHashKey.h
@@ -84,8 +84,8 @@
 
 public:    
     void copyAndTakeOwnership(GrBinHashKey<Entry, StackSize>& key) {
-        memcpy(this, &key, sizeof(*this));
         GrAssert(key.fIsValid);
+        copyFields(key);
         if (fUseHeap) {
             key.fHeapData = NULL;  // ownership transfer
         }
@@ -98,7 +98,7 @@
 
     void deepCopyFrom(const GrBinHashKey<Entry, StackSize>& key) {
         GrAssert(key.fIsValid);
-        memcpy(this, &key, sizeof(key));
+        copyFields(key);
         if (fUseHeap) {
             fHeapData = reinterpret_cast<uint8_t*>(
                 GrMalloc(sizeof(uint8_t) * fPhysicalSize));
@@ -197,6 +197,22 @@
     }
 
 private:
+    void copyFields(const GrBinHashKey<Entry, StackSize>& src) {
+        if (fUseHeap) {
+            GrFree(fHeapData);
+        }
+        // We do a field-by-field copy because this is a non-POD
+        // class, and therefore memcpy would be bad 
+        fA = src.fA;
+        fB = src.fB;
+        fLength = src.fLength;
+        memcpy(fStackData, src.fStackData, StackSize);
+        fHeapData = src.fHeapData;
+        fPhysicalSize = src.fPhysicalSize;
+        fUseHeap = src.fUseHeap;
+        fPass = src.fPass;
+    }
+
     // For computing the Adler-32 hash
     enum Constants {
         kBigPrime = 65521 // largest prime smaller than 2^16