refactor: convert MidiClip events to dynamic allocation to reduce stack size

Co-authored-by: aider (deepseek/deepseek-coder) <aider@aider.chat>
This commit is contained in:
Loic Coenen
2026-05-03 19:03:27 +00:00
parent 791ccf6cf7
commit 6f7bf08ae0
2 changed files with 33 additions and 0 deletions

View File

@@ -32,6 +32,14 @@ static AppState create_test_state(void) {
state.clips[i].buffer_size = 0;
state.clips[i].write_position = 0;
state.clips[i].read_position = 0;
// NEW: Initialize midi clips
state.midi_clips[i].state = CLIP_EMPTY;
state.midi_clips[i].events = (MidiEvent *)calloc(MAX_MIDI_EVENTS, sizeof(MidiEvent));
assert(state.midi_clips[i].events != NULL);
state.midi_clips[i].max_events = MAX_MIDI_EVENTS;
state.midi_clips[i].event_count = 0;
state.midi_clips[i].read_index = 0;
}
return state;
@@ -42,6 +50,8 @@ static void destroy_test_state(AppState *state) {
for (int i = 0; i < MAX_CLIPS; i++) {
free(state->clips[i].buffer);
state->clips[i].buffer = NULL;
free(state->midi_clips[i].events); // NEW
state->midi_clips[i].events = NULL;
}
}
}