[gtk+] csskeyframes: Split new() into alloc() and new()



commit 10fa786dfa718188243935c32deedfa8bec1f208
Author: Benjamin Otte <otte redhat com>
Date:   Fri Feb 21 21:54:40 2014 +0100

    csskeyframes: Split new() into alloc() and new()
    
    The new() function is supposed to return an empty fully initialized
    GtkCssKeyframes object, while the alloc() function just allocates and
    initializes static values. So alloc() can be used for copying or
    resolving keyframes.
    
    Fixes a memleak when resolving keyframes.

 gtk/gtkcsskeyframes.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkcsskeyframes.c b/gtk/gtkcsskeyframes.c
index f25b0c4..5fe9055 100644
--- a/gtk/gtkcsskeyframes.c
+++ b/gtk/gtkcsskeyframes.c
@@ -170,13 +170,23 @@ gtk_css_keyframes_lookup_property (GtkCssKeyframes *keyframes,
 }
 
 static GtkCssKeyframes *
-gtk_css_keyframes_new (void)
+gtk_css_keyframes_alloc (void)
 {
   GtkCssKeyframes *keyframes;
 
   keyframes = g_slice_new0 (GtkCssKeyframes);
   keyframes->ref_count = 1;
 
+  return keyframes;
+}
+
+static GtkCssKeyframes *
+gtk_css_keyframes_new (void)
+{
+  GtkCssKeyframes *keyframes;
+
+  keyframes = gtk_css_keyframes_alloc ();
+
   gtk_css_keyframes_add_keyframe (keyframes, 0);
   gtk_css_keyframes_add_keyframe (keyframes, 1);
 
@@ -439,7 +449,7 @@ _gtk_css_keyframes_compute (GtkCssKeyframes         *keyframes,
   g_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
   g_return_val_if_fail (parent_values == NULL || GTK_IS_CSS_COMPUTED_VALUES (parent_values), NULL);
 
-  resolved = gtk_css_keyframes_new ();
+  resolved = gtk_css_keyframes_alloc ();
   resolved->n_keyframes = keyframes->n_keyframes;
   resolved->keyframe_progress = g_memdup (keyframes->keyframe_progress, keyframes->n_keyframes * sizeof 
(double));
   resolved->n_properties = keyframes->n_properties;


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