OSDN Git Service

Added missing initialization of modLock when DvmDex structures are allocated.
authormsg555 <msg555@gmail.com>
Tue, 19 Feb 2013 14:47:28 +0000 (09:47 -0500)
committerElliott Hughes <enh@google.com>
Tue, 19 Feb 2013 18:56:42 +0000 (10:56 -0800)
The structure is zeroed with dvmAllocRegion (use to be calloc) which for most
implementations of pthreads behaves correctly as if initialized. However, an explicit
initialization is more correct.

Change-Id: I172fed73c2a8a6962d720f78c60436b4f58cc168

vm/DvmDex.cpp

index 035c598..28cd64e 100644 (file)
@@ -79,6 +79,8 @@ static DvmDex* allocateAuxStructures(DexFile* pDexFile)
 
     pDvmDex->pInterfaceCache = dvmAllocAtomicCache(DEX_INTERFACE_CACHE_SIZE);
 
+    dvmInitMutex(&pDvmDex->modLock);
+
     return pDvmDex;
 }
 
@@ -184,6 +186,8 @@ void dvmDexFileFree(DvmDex* pDvmDex)
     if (pDvmDex == NULL)
         return;
 
+    dvmDestroyMutex(&pDvmDex->modLock);
+
     totalSize  = pDvmDex->pHeader->stringIdsSize * sizeof(struct StringObject*);
     totalSize += pDvmDex->pHeader->typeIdsSize * sizeof(struct ClassObject*);
     totalSize += pDvmDex->pHeader->methodIdsSize * sizeof(struct Method*);