summaryrefslogtreecommitdiffstats
path: root/ahl-binding/ahl-deviceenum.c
diff options
context:
space:
mode:
authorTai Vuong <tvuong@audiokinetic.com>2017-11-07 15:40:40 -0500
committerTai Vuong <tvuong@audiokinetic.com>2017-11-07 15:40:40 -0500
commit62d1562669676641613f31f9949008b73d56b458 (patch)
tree3db9d75a615516e4d98df17bf971e023584742ef /ahl-binding/ahl-deviceenum.c
parent2565af906b8e1f40c1e8a1da21b9b29ad995edfe (diff)
Fix memory leak, ducking bug on policy, close stream
Diffstat (limited to 'ahl-binding/ahl-deviceenum.c')
-rw-r--r--ahl-binding/ahl-deviceenum.c50
1 files changed, 27 insertions, 23 deletions
diff --git a/ahl-binding/ahl-deviceenum.c b/ahl-binding/ahl-deviceenum.c
index f672417..b5b2a46 100644
--- a/ahl-binding/ahl-deviceenum.c
+++ b/ahl-binding/ahl-deviceenum.c
@@ -203,31 +203,35 @@ EndpointInfoT * InitEndpointInfo()
return pEndpointInfo;
}
-void TermEndpointInfo( EndpointInfoT * out_pEndpointInfo )
+void TermEndpointInfo( gpointer data )
{
+ EndpointInfoT * out_pEndpointInfo = (EndpointInfoT *)data;
#define SAFE_FREE(__ptr__) if(__ptr__) g_free(__ptr__); __ptr__ = NULL;
- SAFE_FREE(out_pEndpointInfo->gsDeviceName);
- SAFE_FREE(out_pEndpointInfo->gsDeviceDomain);
- SAFE_FREE(out_pEndpointInfo->pRoleName);
- SAFE_FREE(out_pEndpointInfo->gsDeviceURI);
- SAFE_FREE(out_pEndpointInfo->gsHALAPIName);
- SAFE_FREE(out_pEndpointInfo->gsDisplayName);
-
- if (out_pEndpointInfo->pPropTable) {
- // Free json_object for all property values
- GHashTableIter iter;
- gpointer key, value;
- g_hash_table_iter_init (&iter, out_pEndpointInfo->pPropTable);
- while (g_hash_table_iter_next (&iter, &key, &value))
- {
- if (value)
- json_object_put(value);
- }
- g_hash_table_remove_all(out_pEndpointInfo->pPropTable);
- g_hash_table_destroy(out_pEndpointInfo->pPropTable);
- out_pEndpointInfo->pPropTable = NULL;
- }
- // GLib automatically frees item when removed from the array
+ if(out_pEndpointInfo)
+ {
+ SAFE_FREE(out_pEndpointInfo->gsDeviceName);
+ SAFE_FREE(out_pEndpointInfo->gsDeviceDomain);
+ SAFE_FREE(out_pEndpointInfo->pRoleName);
+ SAFE_FREE(out_pEndpointInfo->gsDeviceURI);
+ SAFE_FREE(out_pEndpointInfo->gsHALAPIName);
+ SAFE_FREE(out_pEndpointInfo->gsDisplayName);
+
+ if (out_pEndpointInfo->pPropTable) {
+ // Free json_object for all property values
+ GHashTableIter iter;
+ gpointer key, value;
+ g_hash_table_iter_init (&iter, out_pEndpointInfo->pPropTable);
+ while (g_hash_table_iter_next (&iter, &key, &value))
+ {
+ if (value)
+ json_object_put(value);
+ }
+ g_hash_table_remove_all(out_pEndpointInfo->pPropTable);
+ g_hash_table_destroy(out_pEndpointInfo->pPropTable);
+ out_pEndpointInfo->pPropTable = NULL;
+ }
+ g_slice_free (EndpointInfoT, out_pEndpointInfo);
+ }
}
// For a given audio role