The dynamically created pthread mutex and condition variables
consume pthread resources. They should be destroyed prior to
freeing the structure containing them.
return -err;
}
+static void a2dp_free(struct bluetooth_data *data)
+{
+ pthread_cond_destroy(&data->client_wait);
+ pthread_cond_destroy(&data->thread_wait);
+ pthread_cond_destroy(&data->thread_start);
+ pthread_mutex_destroy(&data->mutex);
+ free(data);
+ return;
+}
+
static void* a2dp_thread(void *d)
{
struct bluetooth_data* data = (struct bluetooth_data*)d;
case A2DP_CMD_QUIT:
bluetooth_close(data);
sbc_finish(&data->sbc);
- free(data);
+ a2dp_free(data);
goto done;
default:
error:
bluetooth_close(data);
sbc_finish(&data->sbc);
- free(data);
+ a2dp_free(data);
return err;
}