[Spice-devel] [PATCH spice-server 3/3] test-gst: Free pipelines

Christophe Fergeau cfergeau at redhat.com
Mon Sep 11 16:25:37 UTC 2017


On Mon, Sep 11, 2017 at 09:12:18AM +0100, Frediano Ziglio wrote:
> Remove some leaks.

I would not really call these a leak, it's just memory which is still
reachable when the program exits, but not explicitly freed.

Acked-by: Christophe Fergeau <cfergeau at redhat.com>


> 
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  server/tests/test-gst.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/server/tests/test-gst.c b/server/tests/test-gst.c
> index 224a891b1..ca187d527 100644
> --- a/server/tests/test-gst.c
> +++ b/server/tests/test-gst.c
> @@ -172,6 +172,7 @@ static TestFrame *gst_to_spice_frame(GstSample *sample);
>  static void bitmap_free(SpiceBitmap *bitmap);
>  static void frame_ref(TestFrame *frame);
>  static void frame_unref(TestFrame *frame);
> +static void pipeline_free(TestPipeline *pipeline);
>  static void pipeline_send_raw_data(TestPipeline *pipeline, VideoBuffer *buffer);
>  static void pipeline_wait_eos(TestPipeline *pipeline);
>  static void create_input_pipeline(const char *input_pipeline,
> @@ -432,6 +433,9 @@ int main(int argc, char *argv[])
>          exit(1);
>      }
>  
> +    pipeline_free(input_pipeline);
> +    pipeline_free(output_pipeline);
> +
>      g_free(encoder_name);
>      g_free(image_format);
>      g_free(input_pipeline_desc);
> @@ -613,6 +617,17 @@ create_pipeline(const char *desc, SampleProc sample_proc, void *param)
>  }
>  
>  static void
> +pipeline_free(TestPipeline *pipeline)
> +{
> +    if (pipeline->appsrc) {
> +        gst_object_unref(pipeline->appsrc);
> +    }
> +    gst_object_unref(pipeline->appsink);
> +    gst_object_unref(pipeline->gst_pipeline);
> +    free(pipeline);
> +}
> +
> +static void
>  create_output_pipeline(const EncoderInfo *encoder, SampleProc sample_proc, void *param)
>  {
>      gchar *desc =
> -- 
> 2.13.5
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel


More information about the Spice-devel mailing list