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

Side by Side Diff: base/base64.cc

Issue 1538743002: Switch to standard integer types in base/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DEPS roll too Created 4 years, 12 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
« no previous file with comments | « base/auto_reset.h ('k') | base/base64url.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/base64.h" 5 #include "base/base64.h"
6 6
7 #include <stddef.h>
8
7 #include "third_party/modp_b64/modp_b64.h" 9 #include "third_party/modp_b64/modp_b64.h"
8 10
9 namespace base { 11 namespace base {
10 12
11 void Base64Encode(const StringPiece& input, std::string* output) { 13 void Base64Encode(const StringPiece& input, std::string* output) {
12 std::string temp; 14 std::string temp;
13 temp.resize(modp_b64_encode_len(input.size())); // makes room for null byte 15 temp.resize(modp_b64_encode_len(input.size())); // makes room for null byte
14 16
15 // modp_b64_encode_len() returns at least 1, so temp[0] is safe to use. 17 // modp_b64_encode_len() returns at least 1, so temp[0] is safe to use.
16 size_t output_size = modp_b64_encode(&(temp[0]), input.data(), input.size()); 18 size_t output_size = modp_b64_encode(&(temp[0]), input.data(), input.size());
(...skipping 11 matching lines...) Expand all
28 size_t output_size = modp_b64_decode(&(temp[0]), input.data(), input_size); 30 size_t output_size = modp_b64_decode(&(temp[0]), input.data(), input_size);
29 if (output_size == MODP_B64_ERROR) 31 if (output_size == MODP_B64_ERROR)
30 return false; 32 return false;
31 33
32 temp.resize(output_size); 34 temp.resize(output_size);
33 output->swap(temp); 35 output->swap(temp);
34 return true; 36 return true;
35 } 37 }
36 38
37 } // namespace base 39 } // namespace base
OLDNEW
« no previous file with comments | « base/auto_reset.h ('k') | base/base64url.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698