summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPiotr Jastrzebski <haaawk@google.com>2014-08-18 13:28:23 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-08-18 13:28:23 +0000
commit932c3a1d0507da5ff8d7183fa5a795bce0a86c19 (patch)
treedbd95a510d3ba04579df07c8b3e38f50ac53e9d7
parentd5c4ace9a850b3a5787592983455dcf0960bd676 (diff)
parent25282774247e841d6d5a3ba903f49866666119b2 (diff)
downloadsystem_core-932c3a1d0507da5ff8d7183fa5a795bce0a86c19.zip
system_core-932c3a1d0507da5ff8d7183fa5a795bce0a86c19.tar.gz
system_core-932c3a1d0507da5ff8d7183fa5a795bce0a86c19.tar.bz2
am 25282774: am 5f231a43: Merge "Fix win_sdk build by not using vector"
* commit '25282774247e841d6d5a3ba903f49866666119b2': Fix win_sdk build by not using vector
-rw-r--r--libziparchive/Android.mk2
-rw-r--r--libziparchive/zip_archive.cc30
2 files changed, 20 insertions, 12 deletions
diff --git a/libziparchive/Android.mk b/libziparchive/Android.mk
index 684c635..d96bc63 100644
--- a/libziparchive/Android.mk
+++ b/libziparchive/Android.mk
@@ -31,7 +31,6 @@ LOCAL_MODULE:= libziparchive
LOCAL_C_INCLUDES += ${includes}
LOCAL_CFLAGS := -Werror
-include external/libcxx/libcxx.mk
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
@@ -44,7 +43,6 @@ LOCAL_STATIC_LIBRARIES := libz libutils
LOCAL_MODULE:= libziparchive-host
LOCAL_CFLAGS := -Werror
LOCAL_MULTILIB := both
-include external/libcxx/libcxx.mk
include $(BUILD_HOST_STATIC_LIBRARY)
include $(CLEAR_VARS)
diff --git a/libziparchive/zip_archive.cc b/libziparchive/zip_archive.cc
index cbe1b14..24088bb 100644
--- a/libziparchive/zip_archive.cc
+++ b/libziparchive/zip_archive.cc
@@ -29,7 +29,6 @@
#include <unistd.h>
#include <utils/Compat.h>
#include <utils/FileMap.h>
-#include <vector>
#include <zlib.h>
#include <JNIHelp.h> // TEMP_FAILURE_RETRY may or may not be in unistd
@@ -889,8 +888,23 @@ static int32_t FindEntry(const ZipArchive* archive, const int ent,
struct IterationHandle {
uint32_t position;
- std::vector<uint8_t> prefix;
+ const uint8_t* prefix;
+ uint16_t prefix_len;
ZipArchive* archive;
+
+ IterationHandle() : prefix(NULL), prefix_len(0) {}
+
+ IterationHandle(const ZipEntryName& prefix_name)
+ : prefix_len(prefix_name.name_length) {
+ uint8_t* prefix_copy = new uint8_t[prefix_len];
+ memcpy(reinterpret_cast<void*>(prefix_copy), prefix_name.name,
+ prefix_len * sizeof(uint8_t));
+ prefix = prefix_copy;
+ }
+
+ ~IterationHandle() {
+ delete [] prefix;
+ }
};
int32_t StartIteration(ZipArchiveHandle handle, void** cookie_ptr,
@@ -902,14 +916,10 @@ int32_t StartIteration(ZipArchiveHandle handle, void** cookie_ptr,
return kInvalidHandle;
}
- IterationHandle* cookie = new IterationHandle();
+ IterationHandle* cookie =
+ optional_prefix != NULL ? new IterationHandle(*optional_prefix) : new IterationHandle();
cookie->position = 0;
cookie->archive = archive;
- if (optional_prefix != NULL) {
- cookie->prefix.insert(cookie->prefix.begin(),
- optional_prefix->name,
- optional_prefix->name + optional_prefix->name_length);
- }
*cookie_ptr = cookie ;
return 0;
@@ -956,8 +966,8 @@ int32_t Next(void* cookie, ZipEntry* data, ZipEntryName* name) {
for (uint32_t i = currentOffset; i < hash_table_length; ++i) {
if (hash_table[i].name != NULL &&
- (handle->prefix.empty() ||
- (memcmp(&(handle->prefix[0]), hash_table[i].name, handle->prefix.size()) == 0))) {
+ (handle->prefix_len == 0 ||
+ (memcmp(handle->prefix, hash_table[i].name, handle->prefix_len) == 0))) {
handle->position = (i + 1);
const int error = FindEntry(archive, i, data);
if (!error) {