This would realloc a buffer for every event, making it absurdly slow for large MIDI files (say, 10k events). Use the somewhat standard heuristic of doubling the requested allocation every time we need to increase the size. This results in a speedup of 40-100x when saving SMF to disk
16 KiB
16 KiB