OSDN Git Service

Initialize the JNI indirect ref table to make Valgrind happy.
authorBen Cheng <bccheng@google.com>
Wed, 30 Nov 2011 18:43:09 +0000 (10:43 -0800)
committerBen Cheng <bccheng@google.com>
Wed, 30 Nov 2011 21:28:58 +0000 (13:28 -0800)
Specifically, this is to eliminate the benign warning about the
'serial' field being uninitialized.

BUG: 5542417
Change-Id: I8550972e70db94f24c47c4e5dea0b59cc5840b48

vm/IndirectRefTable.cpp

index e6d0a7e..c38458d 100644 (file)
@@ -38,9 +38,7 @@ bool IndirectRefTable::init(size_t initialCount,
     if (table_ == NULL) {
         return false;
     }
-#ifndef NDEBUG
     memset(table_, 0xd1, initialCount * sizeof(IndirectRefSlot));
-#endif
 
     segmentState.all = IRT_FIRST_SEGMENT;
     alloc_entries_ = initialCount;
@@ -116,6 +114,9 @@ IndirectRef IndirectRefTable::add(u4 cookie, Object* obj)
                 return NULL;
             }
 
+            memset(newTable + alloc_entries_, 0xd1,
+                   (newSize - alloc_entries_) * sizeof(IndirectRefSlot));
+
             alloc_entries_ = newSize;
             table_ = newTable;
         }