diff options
author | Iliyan Malchev <malchev@google.com> | 2012-02-17 12:15:58 -0800 |
---|---|---|
committer | Iliyan Malchev <malchev@google.com> | 2012-02-17 14:27:13 -0800 |
commit | 7e1d395686a23c8638f72af190f125cf690618a3 (patch) | |
tree | cb54dfd21b057ddaf4dc52cf17c142d3ede4e05f /libs | |
parent | 8d25cb8a640cfe22809bc6afa493a48adc49c4ad (diff) | |
download | frameworks_base-7e1d395686a23c8638f72af190f125cf690618a3.zip frameworks_base-7e1d395686a23c8638f72af190f125cf690618a3.tar.gz frameworks_base-7e1d395686a23c8638f72af190f125cf690618a3.tar.bz2 |
libs/utils: replace malloc() + memset() to zero with calloc()
Change-Id: I8bdf4360147e51e35c162856c9a859aed6acac34
Signed-off-by: Iliyan Malchev <malchev@google.com>
Diffstat (limited to 'libs')
-rw-r--r-- | libs/utils/BackupHelpers.cpp | 5 | ||||
-rw-r--r-- | libs/utils/ResourceTypes.cpp | 9 |
2 files changed, 4 insertions, 10 deletions
diff --git a/libs/utils/BackupHelpers.cpp b/libs/utils/BackupHelpers.cpp index f77a891..214f6d7 100644 --- a/libs/utils/BackupHelpers.cpp +++ b/libs/utils/BackupHelpers.cpp @@ -546,7 +546,7 @@ int write_tarfile(const String8& packageName, const String8& domain, // read/write up to this much at a time. const size_t BUFSIZE = 32 * 1024; - char* buf = new char[BUFSIZE]; + char* buf = (char *)calloc(1,BUFSIZE); char* paxHeader = buf + 512; // use a different chunk of it as separate scratch char* paxData = buf + 1024; @@ -556,9 +556,6 @@ int write_tarfile(const String8& packageName, const String8& domain, goto cleanup; } - // Good to go -- first construct the standard tar header at the start of the buffer - memset(buf, 0, BUFSIZE); - // Magic fields for the ustar file format strcat(buf + 257, "ustar"); strcat(buf + 263, "00"); diff --git a/libs/utils/ResourceTypes.cpp b/libs/utils/ResourceTypes.cpp index 3fa562e..af2f3a9 100644 --- a/libs/utils/ResourceTypes.cpp +++ b/libs/utils/ResourceTypes.cpp @@ -379,8 +379,7 @@ status_t ResStringPool::setTo(const void* data, size_t size, bool copyData) size_t charSize; if (mHeader->flags&ResStringPool_header::UTF8_FLAG) { charSize = sizeof(uint8_t); - mCache = (char16_t**)malloc(sizeof(char16_t**)*mHeader->stringCount); - memset(mCache, 0, sizeof(char16_t**)*mHeader->stringCount); + mCache = (char16_t**)calloc(mHeader->stringCount, sizeof(char16_t**)); } else { charSize = sizeof(char16_t); } @@ -3252,16 +3251,14 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag, // Bag not found, we need to compute it! if (!grp->bags) { - grp->bags = (bag_set***)malloc(sizeof(bag_set*)*grp->typeCount); + grp->bags = (bag_set***)calloc(grp->typeCount, sizeof(bag_set*)); if (!grp->bags) return NO_MEMORY; - memset(grp->bags, 0, sizeof(bag_set*)*grp->typeCount); } bag_set** typeSet = grp->bags[t]; if (!typeSet) { - typeSet = (bag_set**)malloc(sizeof(bag_set*)*NENTRY); + typeSet = (bag_set**)calloc(NENTRY, sizeof(bag_set*)); if (!typeSet) return NO_MEMORY; - memset(typeSet, 0, sizeof(bag_set*)*NENTRY); grp->bags[t] = typeSet; } |