diff options
author | Iliyan Malchev <malchev@google.com> | 2012-02-16 11:23:36 -0800 |
---|---|---|
committer | Iliyan Malchev <malchev@google.com> | 2012-02-16 11:30:09 -0800 |
commit | b74e7190e86d559712747e5cdb31a0d390b7af7d (patch) | |
tree | 7ac5eb198a63b938d42b74f43988bf5b73c8de11 /vm/BitVector.cpp | |
parent | 5bac60aaafca855f68e1f8b5527d4a4b7897f234 (diff) | |
download | android_dalvik-b74e7190e86d559712747e5cdb31a0d390b7af7d.tar.gz android_dalvik-b74e7190e86d559712747e5cdb31a0d390b7af7d.tar.bz2 android_dalvik-b74e7190e86d559712747e5cdb31a0d390b7af7d.zip |
Replace malloc() followed by memset() to zero with calloc()
Bionic's calloc() is smart enough to not zero out memory if it gets that memory
from an anonyous mmap. Thus, if we use malloc for large allocations, we cause
unnecessary memory duplication by following the malloc() with a memset().
An even better approach would be to replace the known large calloc() calls with
dvmAllocRegion() allocation.
Change-Id: Id308f541c9a040d5929bf991b6c2bfdefb823c3c
Diffstat (limited to 'vm/BitVector.cpp')
-rw-r--r-- | vm/BitVector.cpp | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/vm/BitVector.cpp b/vm/BitVector.cpp index 53027897f..8b1d1412a 100644 --- a/vm/BitVector.cpp +++ b/vm/BitVector.cpp @@ -42,8 +42,7 @@ BitVector* dvmAllocBitVector(unsigned int startBits, bool expandable) bv->storageSize = count; bv->expandable = expandable; - bv->storage = (u4*) malloc(count * sizeof(u4)); - memset(bv->storage, 0x00, count * sizeof(u4)); + bv->storage = (u4*) calloc(count, sizeof(u4)); return bv; } |