| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/c/bindings/array.h" | 5 #include <mojo/bindings/array.h> |
| 6 | 6 |
| 7 #include <assert.h> | 7 #include <assert.h> |
| 8 #include <mojo/bindings/buffer.h> |
| 9 #include <mojo/bindings/interface.h> |
| 10 #include <mojo/bindings/internal/type_descriptor.h> |
| 11 #include <mojo/bindings/internal/util.h> |
| 12 #include <mojo/bindings/union.h> |
| 8 #include <stddef.h> | 13 #include <stddef.h> |
| 9 #include <stdint.h> | 14 #include <stdint.h> |
| 10 #include <string.h> | 15 #include <string.h> |
| 11 | 16 |
| 12 #include "mojo/public/c/bindings/buffer.h" | |
| 13 #include "mojo/public/c/bindings/interface.h" | |
| 14 #include "mojo/public/c/bindings/lib/type_descriptor.h" | |
| 15 #include "mojo/public/c/bindings/lib/util.h" | |
| 16 #include "mojo/public/c/bindings/union.h" | |
| 17 | |
| 18 struct MojomArrayHeader* MojomArray_New(struct MojomBuffer* buf, | 17 struct MojomArrayHeader* MojomArray_New(struct MojomBuffer* buf, |
| 19 uint32_t num_elements, | 18 uint32_t num_elements, |
| 20 uint32_t element_byte_size) { | 19 uint32_t element_byte_size) { |
| 21 assert(buf); | 20 assert(buf); |
| 22 | 21 |
| 23 uint64_t num_bytes = sizeof(struct MojomArrayHeader) + | 22 uint64_t num_bytes = sizeof(struct MojomArrayHeader) + |
| 24 (uint64_t)num_elements * element_byte_size; | 23 (uint64_t)num_elements * element_byte_size; |
| 25 if (num_bytes > UINT32_MAX) | 24 if (num_bytes > UINT32_MAX) |
| 26 return NULL; | 25 return NULL; |
| 27 | 26 |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 | 244 |
| 246 if (!MojomType_DispatchDeepCopy(buffer, in_type_desc->elem_type, | 245 if (!MojomType_DispatchDeepCopy(buffer, in_type_desc->elem_type, |
| 247 in_type_desc->elem_descriptor, in_elem_data, | 246 in_type_desc->elem_descriptor, in_elem_data, |
| 248 out_elem_data)) { | 247 out_elem_data)) { |
| 249 return false; | 248 return false; |
| 250 } | 249 } |
| 251 } | 250 } |
| 252 | 251 |
| 253 return true; | 252 return true; |
| 254 } | 253 } |
| OLD | NEW |