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

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: 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
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..a7b351e089b070261fc60c6bfd3204231b4db086
--- /dev/null
+++ b/mojo/public/c/bindings/struct.h
@@ -0,0 +1,28 @@
+// 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 <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(void* data, uint32_t size);
viettrungluu 2016/02/02 00:48:47 const void*? Also, should you use a |size_t| for
+
+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_

Powered by Google App Engine
This is Rietveld 408576698