[gimp] gimp_layer_boundary(): come cleanup



commit a0e1fe6a212f9882f7f19c4c612100f8e59c7001
Author: Michael Natterer <mitch gimp org>
Date:   Mon Aug 31 21:20:52 2009 +0200

    gimp_layer_boundary(): come cleanup
    
    Don't allocate the BoundSegs just to free it a few lines later, simply
    allocate them before they are actually filled.

 app/core/gimplayer.c |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)
---
diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c
index 98ca9d4..4046f9b 100644
--- a/app/core/gimplayer.c
+++ b/app/core/gimplayer.c
@@ -1837,31 +1837,34 @@ gimp_layer_boundary (GimpLayer *layer,
 
   item = GIMP_ITEM (layer);
 
-  /*  Create the four boundary segments that encompass this
-   *  layer's boundary.
-   */
-  new_segs  = g_new (BoundSeg, 4);
-  *num_segs = 4;
-
-  /*  if the layer is a floating selection  */
   if (gimp_layer_is_floating_sel (layer))
     {
-      if (GIMP_IS_CHANNEL (gimp_layer_get_floating_sel_drawable (layer)))
+      GimpDrawable *fs_drawable;
+
+      fs_drawable = gimp_layer_get_floating_sel_drawable (layer);
+
+      if (GIMP_IS_CHANNEL (fs_drawable))
         {
           /*  if the owner drawable is a channel, just return nothing  */
 
-          g_free (new_segs);
           *num_segs = 0;
+
           return NULL;
         }
       else
         {
           /*  otherwise, set the layer to the owner drawable  */
 
-          layer = GIMP_LAYER (gimp_layer_get_floating_sel_drawable (layer));
+          layer = GIMP_LAYER (fs_drawable);
         }
     }
 
+  /*  Create the four boundary segments that encompass this
+   *  layer's boundary.
+   */
+  new_segs  = g_new (BoundSeg, 4);
+  *num_segs = 4;
+
   gimp_item_get_offset (item, &offset_x, &offset_y);
 
   new_segs[0].x1   = offset_x;



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