OLD | NEW |
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/bindings/lib/scratch_buffer.h" | 5 #include "mojo/public/cpp/bindings/lib/scratch_buffer.h" |
6 | 6 |
7 #include <assert.h> | 7 #include <assert.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include <string.h> | 9 #include <string.h> |
10 | 10 |
11 #include <algorithm> | 11 #include <algorithm> |
12 | 12 |
13 #include "mojo/public/bindings/lib/bindings_serialization.h" | 13 #include "mojo/public/cpp/bindings/lib/bindings_serialization.h" |
14 | 14 |
15 // Scrub memory in debug builds to help catch use-after-free bugs. | 15 // Scrub memory in debug builds to help catch use-after-free bugs. |
16 #ifdef NDEBUG | 16 #ifdef NDEBUG |
17 #define DEBUG_SCRUB(address, size) (void) (address), (void) (size) | 17 #define DEBUG_SCRUB(address, size) (void) (address), (void) (size) |
18 #else | 18 #else |
19 #define DEBUG_SCRUB(address, size) memset(address, 0xCD, size) | 19 #define DEBUG_SCRUB(address, size) memset(address, 0xCD, size) |
20 #endif | 20 #endif |
21 | 21 |
22 namespace mojo { | 22 namespace mojo { |
23 namespace internal { | 23 namespace internal { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 Segment* segment = static_cast<Segment*>(malloc(segment_size)); | 89 Segment* segment = static_cast<Segment*>(malloc(segment_size)); |
90 segment->next = overflow_; | 90 segment->next = overflow_; |
91 segment->cursor = reinterpret_cast<char*>(segment + 1); | 91 segment->cursor = reinterpret_cast<char*>(segment + 1); |
92 segment->end = segment->cursor + delta; | 92 segment->end = segment->cursor + delta; |
93 | 93 |
94 overflow_ = segment; | 94 overflow_ = segment; |
95 } | 95 } |
96 | 96 |
97 } // namespace internal | 97 } // namespace internal |
98 } // namespace mojo | 98 } // namespace mojo |
OLD | NEW |