Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: src/platform/update_engine/gzip.cc

Issue 1599029: update engine: 32- and 64-bit compile (Closed)
Patch Set: int32->int32_t, PRIi64, 80 cols for review Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "update_engine/gzip.h" 5 #include "update_engine/gzip.h"
6 #include <stdlib.h> 6 #include <stdlib.h>
7 #include <algorithm> 7 #include <algorithm>
8 #include <zlib.h> 8 #include <zlib.h>
9 #include "chromeos/obsolete_logging.h" 9 #include "chromeos/obsolete_logging.h"
10 #include "update_engine/utils.h" 10 #include "update_engine/utils.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 z_stream stream; 86 z_stream stream;
87 memset(&stream, 0, sizeof(stream)); 87 memset(&stream, 0, sizeof(stream));
88 TEST_AND_RETURN_FALSE(deflateInit2(&stream, 88 TEST_AND_RETURN_FALSE(deflateInit2(&stream,
89 Z_BEST_COMPRESSION, 89 Z_BEST_COMPRESSION,
90 Z_DEFLATED, 90 Z_DEFLATED,
91 16 + MAX_WBITS, 91 16 + MAX_WBITS,
92 9, // most memory used/best compression 92 9, // most memory used/best compression
93 Z_DEFAULT_STRATEGY) == Z_OK); 93 Z_DEFAULT_STRATEGY) == Z_OK);
94 94
95 // guess that output will be roughly half the input size 95 // guess that output will be roughly half the input size
96 *out_size = max(1U, in_size / 2); 96 *out_size = max(static_cast<size_t>(1), in_size / 2);
97 *out = reinterpret_cast<char*>(malloc(*out_size)); 97 *out = reinterpret_cast<char*>(malloc(*out_size));
98 TEST_AND_RETURN_FALSE(*out); 98 TEST_AND_RETURN_FALSE(*out);
99 99
100 // TODO(adlr): ensure that this const_cast is safe. 100 // TODO(adlr): ensure that this const_cast is safe.
101 stream.next_in = const_cast<Bytef*>(reinterpret_cast<const Bytef*>(in)); 101 stream.next_in = const_cast<Bytef*>(reinterpret_cast<const Bytef*>(in));
102 stream.avail_in = in_size; 102 stream.avail_in = in_size;
103 stream.next_out = reinterpret_cast<Bytef*>(*out); 103 stream.next_out = reinterpret_cast<Bytef*>(*out);
104 stream.avail_out = *out_size; 104 stream.avail_out = *out_size;
105 for (;;) { 105 for (;;) {
106 int rc = deflate(&stream, Z_FINISH); 106 int rc = deflate(&stream, Z_FINISH);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 char* out_buf; 176 char* out_buf;
177 size_t out_size; 177 size_t out_size;
178 TEST_AND_RETURN_FALSE(GzipDecompressData(str.data(), str.size(), 178 TEST_AND_RETURN_FALSE(GzipDecompressData(str.data(), str.size(),
179 &out_buf, &out_size)); 179 &out_buf, &out_size));
180 out->insert(out->end(), out_buf, out_buf + out_size); 180 out->insert(out->end(), out_buf, out_buf + out_size);
181 free(out_buf); 181 free(out_buf);
182 return true; 182 return true;
183 } 183 }
184 184
185 } // namespace chromeos_update_engine 185 } // namespace chromeos_update_engine
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698