mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 00:32:11 +01:00
Add dead weight to C++ sizeof values
This commit is contained in:
1 parent
2fff7c782f
commit
4b669a4181
2 files changed
+80
No files matched your search
@@ -1077,6 +1077,16 @@ func (g *gen) writeCppMethods(b *buffer, n *a.Struct) error {
|
||||
b.printf("%s() = delete;\n", fullStructName)
|
||||
b.printf("%s(const %s&) = delete;\n", fullStructName, fullStructName)
|
||||
b.printf("%s& operator=(const %s&) = delete;\n", fullStructName, fullStructName)
|
||||
b.writes("\n")
|
||||
b.writes("// As above, the size of the struct is not part of the public API, and unless\n")
|
||||
b.writes("// WUFFS_IMPLEMENTATION is #define'd, this struct type T should be heap\n")
|
||||
b.writes("// allocated, not stack allocated. Its size is not intended to be known at\n")
|
||||
b.writes("// compile time, but it is unfortunately divulged as a side effect of\n")
|
||||
b.writes("// defining C++ convenience methods. Use \"sizeof__T()\", calling the function,\n")
|
||||
b.writes("// instead of \"sizeof T\", invoking the operator. To make the two values\n")
|
||||
b.writes("// different, so that passing the latter will be rejected by the initialize\n")
|
||||
b.writes("// function, we add an arbitrary amount of dead weight.\n")
|
||||
b.writes("uint8_t dead_weight[123000000]; // 123 MB.\n")
|
||||
b.writes("#endif // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)\n\n")
|
||||
|
||||
// The empty // comment makes clang-format place the function name
|
||||
|
||||
@@ -2696,6 +2696,16 @@ struct wuffs_adler32__hasher__struct {
|
||||
wuffs_adler32__hasher__struct(const wuffs_adler32__hasher__struct&) = delete;
|
||||
wuffs_adler32__hasher__struct& operator=(
|
||||
const wuffs_adler32__hasher__struct&) = delete;
|
||||
|
||||
// As above, the size of the struct is not part of the public API, and unless
|
||||
// WUFFS_IMPLEMENTATION is #define'd, this struct type T should be heap
|
||||
// allocated, not stack allocated. Its size is not intended to be known at
|
||||
// compile time, but it is unfortunately divulged as a side effect of
|
||||
// defining C++ convenience methods. Use "sizeof__T()", calling the function,
|
||||
// instead of "sizeof T", invoking the operator. To make the two values
|
||||
// different, so that passing the latter will be rejected by the initialize
|
||||
// function, we add an arbitrary amount of dead weight.
|
||||
uint8_t dead_weight[123000000]; // 123 MB.
|
||||
#endif // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT //
|
||||
@@ -2814,6 +2824,16 @@ struct wuffs_crc32__ieee_hasher__struct {
|
||||
delete;
|
||||
wuffs_crc32__ieee_hasher__struct& operator=(
|
||||
const wuffs_crc32__ieee_hasher__struct&) = delete;
|
||||
|
||||
// As above, the size of the struct is not part of the public API, and unless
|
||||
// WUFFS_IMPLEMENTATION is #define'd, this struct type T should be heap
|
||||
// allocated, not stack allocated. Its size is not intended to be known at
|
||||
// compile time, but it is unfortunately divulged as a side effect of
|
||||
// defining C++ convenience methods. Use "sizeof__T()", calling the function,
|
||||
// instead of "sizeof T", invoking the operator. To make the two values
|
||||
// different, so that passing the latter will be rejected by the initialize
|
||||
// function, we add an arbitrary amount of dead weight.
|
||||
uint8_t dead_weight[123000000]; // 123 MB.
|
||||
#endif // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT //
|
||||
@@ -3000,6 +3020,16 @@ struct wuffs_deflate__decoder__struct {
|
||||
delete;
|
||||
wuffs_deflate__decoder__struct& operator=(
|
||||
const wuffs_deflate__decoder__struct&) = delete;
|
||||
|
||||
// As above, the size of the struct is not part of the public API, and unless
|
||||
// WUFFS_IMPLEMENTATION is #define'd, this struct type T should be heap
|
||||
// allocated, not stack allocated. Its size is not intended to be known at
|
||||
// compile time, but it is unfortunately divulged as a side effect of
|
||||
// defining C++ convenience methods. Use "sizeof__T()", calling the function,
|
||||
// instead of "sizeof T", invoking the operator. To make the two values
|
||||
// different, so that passing the latter will be rejected by the initialize
|
||||
// function, we add an arbitrary amount of dead weight.
|
||||
uint8_t dead_weight[123000000]; // 123 MB.
|
||||
#endif // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT //
|
||||
@@ -3153,6 +3183,16 @@ struct wuffs_lzw__decoder__struct {
|
||||
wuffs_lzw__decoder__struct(const wuffs_lzw__decoder__struct&) = delete;
|
||||
wuffs_lzw__decoder__struct& operator=(const wuffs_lzw__decoder__struct&) =
|
||||
delete;
|
||||
|
||||
// As above, the size of the struct is not part of the public API, and unless
|
||||
// WUFFS_IMPLEMENTATION is #define'd, this struct type T should be heap
|
||||
// allocated, not stack allocated. Its size is not intended to be known at
|
||||
// compile time, but it is unfortunately divulged as a side effect of
|
||||
// defining C++ convenience methods. Use "sizeof__T()", calling the function,
|
||||
// instead of "sizeof T", invoking the operator. To make the two values
|
||||
// different, so that passing the latter will be rejected by the initialize
|
||||
// function, we add an arbitrary amount of dead weight.
|
||||
uint8_t dead_weight[123000000]; // 123 MB.
|
||||
#endif // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT //
|
||||
@@ -3465,6 +3505,16 @@ struct wuffs_gif__decoder__struct {
|
||||
wuffs_gif__decoder__struct(const wuffs_gif__decoder__struct&) = delete;
|
||||
wuffs_gif__decoder__struct& operator=(const wuffs_gif__decoder__struct&) =
|
||||
delete;
|
||||
|
||||
// As above, the size of the struct is not part of the public API, and unless
|
||||
// WUFFS_IMPLEMENTATION is #define'd, this struct type T should be heap
|
||||
// allocated, not stack allocated. Its size is not intended to be known at
|
||||
// compile time, but it is unfortunately divulged as a side effect of
|
||||
// defining C++ convenience methods. Use "sizeof__T()", calling the function,
|
||||
// instead of "sizeof T", invoking the operator. To make the two values
|
||||
// different, so that passing the latter will be rejected by the initialize
|
||||
// function, we add an arbitrary amount of dead weight.
|
||||
uint8_t dead_weight[123000000]; // 123 MB.
|
||||
#endif // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT //
|
||||
@@ -3670,6 +3720,16 @@ struct wuffs_gzip__decoder__struct {
|
||||
wuffs_gzip__decoder__struct(const wuffs_gzip__decoder__struct&) = delete;
|
||||
wuffs_gzip__decoder__struct& operator=(const wuffs_gzip__decoder__struct&) =
|
||||
delete;
|
||||
|
||||
// As above, the size of the struct is not part of the public API, and unless
|
||||
// WUFFS_IMPLEMENTATION is #define'd, this struct type T should be heap
|
||||
// allocated, not stack allocated. Its size is not intended to be known at
|
||||
// compile time, but it is unfortunately divulged as a side effect of
|
||||
// defining C++ convenience methods. Use "sizeof__T()", calling the function,
|
||||
// instead of "sizeof T", invoking the operator. To make the two values
|
||||
// different, so that passing the latter will be rejected by the initialize
|
||||
// function, we add an arbitrary amount of dead weight.
|
||||
uint8_t dead_weight[123000000]; // 123 MB.
|
||||
#endif // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT //
|
||||
@@ -3829,6 +3889,16 @@ struct wuffs_zlib__decoder__struct {
|
||||
wuffs_zlib__decoder__struct(const wuffs_zlib__decoder__struct&) = delete;
|
||||
wuffs_zlib__decoder__struct& operator=(const wuffs_zlib__decoder__struct&) =
|
||||
delete;
|
||||
|
||||
// As above, the size of the struct is not part of the public API, and unless
|
||||
// WUFFS_IMPLEMENTATION is #define'd, this struct type T should be heap
|
||||
// allocated, not stack allocated. Its size is not intended to be known at
|
||||
// compile time, but it is unfortunately divulged as a side effect of
|
||||
// defining C++ convenience methods. Use "sizeof__T()", calling the function,
|
||||
// instead of "sizeof T", invoking the operator. To make the two values
|
||||
// different, so that passing the latter will be rejected by the initialize
|
||||
// function, we add an arbitrary amount of dead weight.
|
||||
uint8_t dead_weight[123000000]; // 123 MB.
|
||||
#endif // (__cplusplus >= 201103L) && !defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT //
|
||||
|
||||
Reference in new issue
Block a user