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

Unified Diff: mojo/public/c/bindings/struct.h

Issue 1654373002: C types and utilities to validate and access struct and message headers (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: review feedback, for trybots Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/c/bindings/message.h ('k') | mojo/public/c/bindings/tests/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/c/bindings/struct.h
diff --git a/mojo/public/c/bindings/struct.h b/mojo/public/c/bindings/struct.h
new file mode 100644
index 0000000000000000000000000000000000000000..bdc893ef05acd11bbfca6efee4e4704b8e15e512
--- /dev/null
+++ b/mojo/public/c/bindings/struct.h
@@ -0,0 +1,29 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MOJO_PUBLIC_C_BINDINGS_STRUCT_H_
+#define MOJO_PUBLIC_C_BINDINGS_STRUCT_H_
+
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Validates that a given buffer has a mojo struct header and that the size of
+// the struct in the header matches the size of the buffer.
+bool mojo_validate_struct_header(const void* data, size_t size);
+
+typedef struct struct_header {
+ uint32_t num_bytes;
+ uint32_t version;
+} mojo_struct_header_t;
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // MOJO_PUBLIC_C_BINDINGS_STRUCT_H_
« no previous file with comments | « mojo/public/c/bindings/message.h ('k') | mojo/public/c/bindings/tests/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698