@@ -66,7 +66,7 @@ struct MsgpackSchemaPacker : msgpack::packer<msgpack::sbuffer> {
66
66
67
67
// Note: if this fails to compile, check first in list of template Arg's
68
68
// it may need a msgpack_schema_pack specialization (particularly if it doesn't define MSGPACK_FIELDS).
69
- (_msgpack_schema_pack (*this , Args{} ), ...); /* pack schemas of all template Args */
69
+ (_msgpack_schema_pack (*this , *std::make_unique< Args>() ), ...); /* pack schemas of all template Args */
70
70
}
71
71
/* *
72
72
* @brief Encode a type that defines msgpack based on its key value pairs.
@@ -108,7 +108,10 @@ concept SchemaPackable = requires(T value, MsgpackSchemaPacker packer) { msgpack
108
108
109
109
// Helper for packing (key, value, key, value, ...) arguments
110
110
template <typename Value, typename ... Rest>
111
- inline void _schema_pack_map_content (MsgpackSchemaPacker& packer, std::string key, Value value, Rest... rest)
111
+ inline void _schema_pack_map_content (MsgpackSchemaPacker& packer,
112
+ std::string key,
113
+ const Value& value,
114
+ const Rest&... rest)
112
115
{
113
116
static_assert (
114
117
msgpack_concepts::SchemaPackable<Value>,
@@ -200,7 +203,9 @@ inline void msgpack_schema_pack(MsgpackSchemaPacker& packer, std::array<T, N> co
200
203
packer.pack (" array" );
201
204
// That has a size 2 tuple as its 2nd arg
202
205
packer.pack_array (2 ); /* param list format for consistency*/
203
- _msgpack_schema_pack (packer, T{});
206
+ // To avoid WASM problems with large stack objects, we use a heap allocation.
207
+ // Small note: This works because make_unique goes of scope only when the whole line is done.
208
+ _msgpack_schema_pack (packer, *std::make_unique<T>());
204
209
packer.pack (N);
205
210
}
206
211
0 commit comments