Fix deserialization format of events

Apparently it uses VLAs, but in a very sneaky way.
This commit is contained in:
Robbert van der Helm
2020-03-09 17:20:15 +01:00
parent 69008e97a4
commit 10b6121cb8
2 changed files with 18 additions and 7 deletions
+11 -2
View File
@@ -80,9 +80,9 @@ overload(Ts...)->overload<Ts...>;
*
* Before serialization the events are read from a C-style array into a vector
* using this class's constructor, and after deserializing the original struct
* can be obtained again usign the `as_c_events()` method.
* can be reconstructed usign the `as_c_events()` method.
*/
class DynamicVstEvents {
class alignas(16) DynamicVstEvents {
public:
DynamicVstEvents(){};
@@ -107,6 +107,15 @@ class DynamicVstEvents {
* vector has been filled.
*/
VstEvents vst_events;
/**
* The `VstEvents` struct is defined to look like it contains a one or two
* element array of `VstEvent` pointers. The actual truth is that the
* `VstEvents::event` array is actually a variable length array with length
* `VstEvents::numEvents`. This is probably not part of any header files
* because VLAs are not part of any C++ standard. This struct is here to
* make sure there is enough room to copy the elements into.
*/
size_t dummy[max_midi_events];
};
/**