[gtk+] printjob: Clarify array ownership in gtk_print_job_set_page_ranges()



commit 876e99df361678a3ff7b38c02f966a67ae537f82
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Fri Mar 24 16:41:47 2017 +0100

    printjob: Clarify array ownership in gtk_print_job_set_page_ranges()
    
    Add a documentation annotation saying that set_page_ranges transfers
    ownership of the GtkPageRange array.
    Add a g_free() call to fix a memory leak when set_page_ranges is
    used repeatedly.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=780234

 gtk/gtkprintjob.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkprintjob.c b/gtk/gtkprintjob.c
index 571d2b0..e74fdc0 100644
--- a/gtk/gtkprintjob.c
+++ b/gtk/gtkprintjob.c
@@ -781,7 +781,7 @@ gtk_print_job_get_page_ranges (GtkPrintJob *job,
 /**
  * gtk_print_job_set_page_ranges:
  * @job: a #GtkPrintJob
- * @ranges: (array length=n_ranges): pointer to an array of
+ * @ranges: (array length=n_ranges) (transfer full): pointer to an array of
  *    #GtkPageRange structs
  * @n_ranges: the length of the @ranges array
  *
@@ -794,6 +794,7 @@ gtk_print_job_set_page_ranges (GtkPrintJob  *job,
                                GtkPageRange *ranges,
                                gint          n_ranges)
 {
+  g_free (job->priv->page_ranges);
   job->priv->page_ranges = ranges;
   job->priv->num_page_ranges = n_ranges;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]