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

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

Issue 2062323002: Mojo C bindings library pt1: MojomBuffer (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: fix rounding on large ints. more unittests Created 4 years, 6 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/buffer.h
diff --git a/mojo/public/c/bindings/buffer.h b/mojo/public/c/bindings/buffer.h
new file mode 100644
index 0000000000000000000000000000000000000000..0370511e1d9e132fe11768320fd40f35be13fbd1
--- /dev/null
+++ b/mojo/public/c/bindings/buffer.h
@@ -0,0 +1,31 @@
+// 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_BUFFER_H_
+#define MOJO_PUBLIC_C_BINDINGS_BUFFER_H_
+
+#include <stdint.h>
+
+#include "mojo/public/c/system/macros.h"
+
+MOJO_BEGIN_EXTERN_C
+
+// |MojomBuffer| is used to track a buffer state for mojom serialization. The
+// user must initialize this struct themselves. See the fields for details.
+struct MojomBuffer {
+ char* buf;
+ // The number of bytes described by |buf|.
+ uint32_t buf_size;
+ // Must be initialized to 0. MojomBuffer_Allocate() will update it as it
+ // consumes |buf|.
+ uint32_t num_bytes_used;
+};
+
+// Allocates |num_bytes| (rounded to 8 bytes) from |buf|. Returns NULL if
+// there isn't enough space left to allocate, or when |num_bytes| is 0.
+void* MojomBuffer_Allocate(struct MojomBuffer* buf, uint32_t num_bytes);
+
+MOJO_END_EXTERN_C
+
+#endif // MOJO_PUBLIC_C_BINDINGS_BUFFER_H_

Powered by Google App Engine
This is Rietveld 408576698