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

Side by Side Diff: mojo/public/c/bindings/lib/map.c

Issue 2232833003: Change the canonical way to include the C bindings headers to <mojo/bindings/*.h>. (Closed) Base URL: https://github.com/domokit/mojo.git@work791_mojo_tests
Patch Set: rebased Created 4 years, 4 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 | « mojo/public/c/bindings/lib/buffer.c ('k') | mojo/public/c/bindings/lib/message.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "mojo/public/c/bindings/map.h"
6
7 struct MojomMapLayout {
8 struct MojomStructHeader header_;
9 union MojomArrayHeaderPtr keys;
10 union MojomArrayHeaderPtr values;
11 };
12 MOJO_STATIC_ASSERT(sizeof(struct MojomMapLayout) == 24u,
13 "MojomMapLayout is an invalid size.");
14
15 MojomValidationResult MojomMap_Validate(
16 const struct MojomTypeDescriptorStruct* in_type_desc,
17 const struct MojomStructHeader* in_struct,
18 uint32_t in_buf_size,
19 uint32_t in_num_handles,
20 struct MojomValidationContext* inout_context) {
21 // A mojom map consists of 2 arrays (pointers), both of equal size.
22 const struct MojomMapLayout* map = (const struct MojomMapLayout*)in_struct;
23 struct MojomArrayHeader* keys_arr =
24 (struct MojomArrayHeader*)((char*)map +
25 (offsetof(struct MojomMapLayout, keys) +
26 map->keys.offset));
27 struct MojomArrayHeader* values_arr =
28 (struct MojomArrayHeader*)((char*)map +
29 (offsetof(struct MojomMapLayout, values) +
30 map->values.offset));
31
32 if (keys_arr->num_elements != values_arr->num_elements)
33 return MOJOM_VALIDATION_DIFFERENT_SIZED_ARRAYS_IN_MAP;
34
35 return MOJOM_VALIDATION_ERROR_NONE;
36 }
OLDNEW
« no previous file with comments | « mojo/public/c/bindings/lib/buffer.c ('k') | mojo/public/c/bindings/lib/message.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698