am 5f231a43: Merge "Fix win_sdk build by not using vector"

* commit '5f231a43b342fcfbd778d14f953b0b63715ee7f2':
  Fix win_sdk build by not using vector
This commit is contained in:
Piotr Jastrzebski 2014-08-18 13:20:43 +00:00 committed by Android Git Automerger
commit 2528277424
2 changed files with 20 additions and 12 deletions

View File

@ -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)

View File

@ -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) {