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

Unified Diff: third_party/brotli/include/brotli/types.h

Issue 2537133002: Update brotli to v1.0.0-snapshot. (Closed)
Patch Set: Fixed typo Created 4 years 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 | « third_party/brotli/include/brotli/port.h ('k') | third_party/brotli/tools/bro.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/brotli/include/brotli/types.h
diff --git a/third_party/brotli/dec/types.h b/third_party/brotli/include/brotli/types.h
similarity index 24%
rename from third_party/brotli/dec/types.h
rename to third_party/brotli/include/brotli/types.h
index 0f7a0216a0449c68e5416e5af363274c3e8fe691..f982c6423de1aaa12bb3940e5fde497c41377c26 100644
--- a/third_party/brotli/dec/types.h
+++ b/third_party/brotli/include/brotli/types.h
@@ -4,10 +4,13 @@
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
*/
-/* Common types */
+/**
+ * @file
+ * Common types used in decoder and encoder API.
+ */
-#ifndef BROTLI_DEC_TYPES_H_
-#define BROTLI_DEC_TYPES_H_
+#ifndef BROTLI_COMMON_TYPES_H_
+#define BROTLI_COMMON_TYPES_H_
#include <stddef.h> /* for size_t */
@@ -24,15 +27,64 @@ typedef __int64 int64_t;
#include <stdint.h>
#endif /* defined(_MSC_VER) && (_MSC_VER < 1600) */
-/* Allocating function pointer. Function MUST return 0 in the case of failure.
- Otherwise it MUST return a valid pointer to a memory region of at least
- size length. Neither items nor size are allowed to be 0.
- opaque argument is a pointer provided by client and could be used to bind
- function to specific object (memory pool). */
+/**
+ * A portable @c bool replacement.
+ *
+ * ::BROTLI_BOOL is a "documentation" type: actually it is @c int, but in API it
+ * denotes a type, whose only values are ::BROTLI_TRUE and ::BROTLI_FALSE.
+ *
+ * ::BROTLI_BOOL values passed to Brotli should either be ::BROTLI_TRUE or
+ * ::BROTLI_FALSE, or be a result of ::TO_BROTLI_BOOL macros.
+ *
+ * ::BROTLI_BOOL values returned by Brotli should not be tested for equality
+ * with @c true, @c false, ::BROTLI_TRUE, ::BROTLI_FALSE, but rather should be
+ * evaluated, for example: @code{.cpp}
+ * if (SomeBrotliFunction(encoder, BROTLI_TRUE) &&
+ * !OtherBrotliFunction(decoder, BROTLI_FALSE)) {
+ * bool x = !!YetAnotherBrotliFunction(encoder, TO_BROLTI_BOOL(2 * 2 == 4));
+ * DoSomething(x);
+ * }
+ * @endcode
+ */
+#define BROTLI_BOOL int
+/** Portable @c true replacement. */
+#define BROTLI_TRUE 1
+/** Portable @c false replacement. */
+#define BROTLI_FALSE 0
+/** @c bool to ::BROTLI_BOOL conversion macros. */
+#define TO_BROTLI_BOOL(X) (!!(X) ? BROTLI_TRUE : BROTLI_FALSE)
+
+#define BROTLI_MAKE_UINT64_T(high, low) ((((uint64_t)(high)) << 32) | low)
+
+#define BROTLI_UINT32_MAX (~((uint32_t)0))
+#define BROTLI_SIZE_MAX (~((size_t)0))
+
+/**
+ * Allocating function pointer type.
+ *
+ * @param opaque custom memory manager handle provided by client
+ * @param size requested memory region size; can not be @c 0
+ * @returns @c 0 in the case of failure
+ * @returns a valid pointer to a memory region of at least @p size bytes
+ * long otherwise
+ */
typedef void* (*brotli_alloc_func)(void* opaque, size_t size);
-/* Deallocating function pointer. Function SHOULD be no-op in the case the
- address is 0. */
+/**
+ * Deallocating function pointer type.
+ *
+ * This function @b SHOULD do nothing if @p address is @c 0.
+ *
+ * @param opaque custom memory manager handle provided by client
+ * @param address memory region pointer returned by ::brotli_alloc_func, or @c 0
+ */
typedef void (*brotli_free_func)(void* opaque, void* address);
-#endif /* BROTLI_DEC_TYPES_H_ */
+#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
+ !defined(__cplusplus)
+#define BROTLI_ARRAY_PARAM(L) L
+#else
+#define BROTLI_ARRAY_PARAM(L)
+#endif
+
+#endif /* BROTLI_COMMON_TYPES_H_ */
« no previous file with comments | « third_party/brotli/include/brotli/port.h ('k') | third_party/brotli/tools/bro.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698