@@ -185,7 +185,7 @@ pipe_custom_remove_data (const pipe_custom_type_e type, const gchar * name)
185185
186186 g_ml_custom_data = g_list_delete_link (g_ml_custom_data , link );
187187
188- g_free ( data -> name );
188+ g_clear_pointer ( & data -> name , g_free );
189189 g_free (data );
190190 }
191191
@@ -516,8 +516,7 @@ free_element_handle (gpointer data)
516516 NULL , NULL );
517517 }
518518
519- g_free (item -> callback_info );
520- item -> callback_info = NULL ;
519+ g_clear_pointer (& item -> callback_info , g_free );
521520 g_free (item );
522521}
523522
@@ -576,13 +575,10 @@ cleanup_node (gpointer data)
576575 e -> custom_destroy (e -> custom_data , e );
577576 }
578577
579- g_free (e -> name );
580- if (e -> src )
581- gst_object_unref (e -> src );
582- if (e -> sink )
583- gst_object_unref (e -> sink );
584-
585- gst_object_unref (e -> element );
578+ g_clear_pointer (& e -> name , g_free );
579+ g_clear_pointer (& e -> src , gst_object_unref );
580+ g_clear_pointer (& e -> sink , gst_object_unref );
581+ g_clear_pointer (& e -> element , gst_object_unref );
586582
587583 gst_tensors_info_free (& e -> tensors_info );
588584
@@ -605,7 +601,7 @@ cleanup_resource (gpointer data)
605601 release_tizen_resource (res -> handle , res -> type );
606602 }
607603
608- g_free ( res -> type );
604+ g_clear_pointer ( & res -> type , g_free );
609605 g_free (res );
610606}
611607
@@ -2137,8 +2133,7 @@ ml_pipeline_switch_get_pad_list (ml_pipeline_switch_h h, char ***list)
21372133
21382134 if (i > counter ) {
21392135 g_list_free_full (dllist , g_free ); /* This frees all strings as well */
2140- g_free (* list );
2141- * list = NULL ;
2136+ g_clear_pointer (list , g_free );
21422137
21432138 _ml_error_report
21442139 ("Internal data inconsistency. This could be a bug in nnstreamer. Switch [%s]." ,
@@ -2746,7 +2741,7 @@ ml_pipeline_custom_free_handle (ml_custom_filter_s * custom)
27462741 if (custom ) {
27472742 g_mutex_lock (& custom -> lock );
27482743
2749- g_free ( custom -> name );
2744+ g_clear_pointer ( & custom -> name , g_free );
27502745 ml_tensors_info_destroy (custom -> in_info );
27512746 ml_tensors_info_destroy (custom -> out_info );
27522747
@@ -3056,7 +3051,7 @@ ml_pipeline_if_custom_free (ml_if_custom_s * custom)
30563051 if (custom ) {
30573052 g_mutex_lock (& custom -> lock );
30583053
3059- g_free ( custom -> name );
3054+ g_clear_pointer ( & custom -> name , g_free );
30603055
30613056 g_mutex_unlock (& custom -> lock );
30623057 g_mutex_clear (& custom -> lock );
0 commit comments