Free up scanned kit memory on cleanup. Fixes a memory leak

This commit is contained in:
Nick Lanham 2012-02-13 16:20:29 +01:00
parent 45b2eeae22
commit dc17012ed6
3 changed files with 13 additions and 0 deletions

1
drmr.c
View File

@ -263,6 +263,7 @@ static void cleanup(LV2_Handle instance) {
pthread_join(drmr->load_thread, 0);
if (drmr->num_samples > 0)
free_samples(drmr->samples,drmr->num_samples);
free_kits(drmr->kits);
free(drmr->gains);
free(instance);
}

View File

@ -326,6 +326,17 @@ void free_samples(drmr_sample* samples, int num_samples) {
free(samples);
}
void free_kits(kits* kits) {
int i;
for (i = 0;i < kits->num_kits;i++) {
free(kits->kits[i].name);
free(kits->kits[i].desc);
free(kits->kits[i].path);
}
free(kits->kits);
free(kits);
}
int load_sample(char* path, drmr_layer* layer) {
SNDFILE* sndf;
int size;

View File

@ -214,6 +214,7 @@ static void cleanup(LV2UI_Handle handle) {
gtk_widget_destroy(ui->drmr_widget);
if (ui->gain_sliders) free(ui->gain_sliders);
if (ui->pan_sliders) free(ui->pan_sliders);
free_kits(ui->kits);
free(ui);
}