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

Side by Side Diff: mojo/public/cpp/bindings/lib/string_serialization.cc

Issue 613053002: Mojo: NULL -> nullptr in mojo/public/cpp/bindings and also for the bindings generator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "mojo/public/cpp/bindings/lib/string_serialization.h" 5 #include "mojo/public/cpp/bindings/lib/string_serialization.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 namespace mojo { 9 namespace mojo {
10 10
11 size_t GetSerializedSize_(const String& input) { 11 size_t GetSerializedSize_(const String& input) {
12 if (!input) 12 if (!input)
13 return 0; 13 return 0;
14 return internal::Align(sizeof(internal::String_Data) + input.size()); 14 return internal::Align(sizeof(internal::String_Data) + input.size());
15 } 15 }
16 16
17 void Serialize_(const String& input, internal::Buffer* buf, 17 void Serialize_(const String& input, internal::Buffer* buf,
18 internal::String_Data** output) { 18 internal::String_Data** output) {
19 if (input) { 19 if (input) {
20 internal::String_Data* result = 20 internal::String_Data* result =
21 internal::String_Data::New(input.size(), buf); 21 internal::String_Data::New(input.size(), buf);
22 if (result) 22 if (result)
23 memcpy(result->storage(), input.data(), input.size()); 23 memcpy(result->storage(), input.data(), input.size());
24 *output = result; 24 *output = result;
25 } else { 25 } else {
26 *output = NULL; 26 *output = nullptr;
27 } 27 }
28 } 28 }
29 29
30 void Deserialize_(internal::String_Data* input, String* output) { 30 void Deserialize_(internal::String_Data* input, String* output) {
31 if (input) { 31 if (input) {
32 String result(input->storage(), input->size()); 32 String result(input->storage(), input->size());
33 result.Swap(output); 33 result.Swap(output);
34 } else { 34 } else {
35 output->reset(); 35 output->reset();
36 } 36 }
37 } 37 }
38 38
39 } // namespace mojo 39 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/shared_ptr.h ('k') | mojo/public/cpp/bindings/lib/validation_errors.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698