summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPiotr Jastrzebski2014-08-18 05:37:45 -0500
committerPiotr Jastrzebski2014-08-18 08:04:56 -0500
commit8e08536108d2b5a7f4f9a4b008987b54602fda18 (patch)
treed9656f47c9d2603d2cef4e4e753456284b5c9c94 /libziparchive/zip_archive.cc
parentc0879ee9d39ad4e9a2628c5cf1aaf4f843c13760 (diff)
downloadplatform-system-core-8e08536108d2b5a7f4f9a4b008987b54602fda18.tar.gz
platform-system-core-8e08536108d2b5a7f4f9a4b008987b54602fda18.tar.xz
platform-system-core-8e08536108d2b5a7f4f9a4b008987b54602fda18.zip
Fix win_sdk build by not using vector
Change-Id: I4e9ee4286ea29e1f5f2ee477525e79bfa16ad9a0
Diffstat (limited to 'libziparchive/zip_archive.cc')
-rw-r--r--libziparchive/zip_archive.cc30
1 files changed, 20 insertions, 10 deletions
diff --git a/libziparchive/zip_archive.cc b/libziparchive/zip_archive.cc
index cbe1b14ae..24088bb93 100644
--- a/libziparchive/zip_archive.cc
+++ b/libziparchive/zip_archive.cc
@@ -29,7 +29,6 @@
29#include <unistd.h> 29#include <unistd.h>
30#include <utils/Compat.h> 30#include <utils/Compat.h>
31#include <utils/FileMap.h> 31#include <utils/FileMap.h>
32#include <vector>
33#include <zlib.h> 32#include <zlib.h>
34 33
35#include <JNIHelp.h> // TEMP_FAILURE_RETRY may or may not be in unistd 34#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,
889 888
890struct IterationHandle { 889struct IterationHandle {
891 uint32_t position; 890 uint32_t position;
892 std::vector<uint8_t> prefix; 891 const uint8_t* prefix;
892 uint16_t prefix_len;
893 ZipArchive* archive; 893 ZipArchive* archive;
894
895 IterationHandle() : prefix(NULL), prefix_len(0) {}
896
897 IterationHandle(const ZipEntryName& prefix_name)
898 : prefix_len(prefix_name.name_length) {
899 uint8_t* prefix_copy = new uint8_t[prefix_len];
900 memcpy(reinterpret_cast<void*>(prefix_copy), prefix_name.name,
901 prefix_len * sizeof(uint8_t));
902 prefix = prefix_copy;
903 }
904
905 ~IterationHandle() {
906 delete [] prefix;
907 }
894}; 908};
895 909
896int32_t StartIteration(ZipArchiveHandle handle, void** cookie_ptr, 910int32_t StartIteration(ZipArchiveHandle handle, void** cookie_ptr,
@@ -902,14 +916,10 @@ int32_t StartIteration(ZipArchiveHandle handle, void** cookie_ptr,
902 return kInvalidHandle; 916 return kInvalidHandle;
903 } 917 }
904 918
905 IterationHandle* cookie = new IterationHandle(); 919 IterationHandle* cookie =
920 optional_prefix != NULL ? new IterationHandle(*optional_prefix) : new IterationHandle();
906 cookie->position = 0; 921 cookie->position = 0;
907 cookie->archive = archive; 922 cookie->archive = archive;
908 if (optional_prefix != NULL) {
909 cookie->prefix.insert(cookie->prefix.begin(),
910 optional_prefix->name,
911 optional_prefix->name + optional_prefix->name_length);
912 }
913 923
914 *cookie_ptr = cookie ; 924 *cookie_ptr = cookie ;
915 return 0; 925 return 0;
@@ -956,8 +966,8 @@ int32_t Next(void* cookie, ZipEntry* data, ZipEntryName* name) {
956 966
957 for (uint32_t i = currentOffset; i < hash_table_length; ++i) { 967 for (uint32_t i = currentOffset; i < hash_table_length; ++i) {
958 if (hash_table[i].name != NULL && 968 if (hash_table[i].name != NULL &&
959 (handle->prefix.empty() || 969 (handle->prefix_len == 0 ||
960 (memcmp(&(handle->prefix[0]), hash_table[i].name, handle->prefix.size()) == 0))) { 970 (memcmp(handle->prefix, hash_table[i].name, handle->prefix_len) == 0))) {
961 handle->position = (i + 1); 971 handle->position = (i + 1);
962 const int error = FindEntry(archive, i, data); 972 const int error = FindEntry(archive, i, data);
963 if (!error) { 973 if (!error) {