Author: spouliot
Date: 2007-03-30 12:03:24 -0500 (Fri, 30 Mar 2007)
New Revision: 75218

Modified:
   trunk/libgdiplus/src/ChangeLog
   trunk/libgdiplus/src/brush.c
   trunk/libgdiplus/src/hatchbrush.c
   trunk/libgdiplus/src/lineargradientbrush.c
   trunk/libgdiplus/src/pathgradientbrush.c
   trunk/libgdiplus/src/solidbrush.c
   trunk/libgdiplus/src/texturebrush.c
Log:
2007-03-30  Sebastien Pouliot  <[EMAIL PROTECTED]> 

        * brush.c: Change contract between GdipDeleteBrush and the destroy
        function of the specialized brushes. The NULL check and the GdipFree
        of the brush is now done centrally.
        * hatchbrush.c: Simplify with new contract.
        * lineargradientbrush.c: Simplify with new contract.
        * pathgradientbrush.c: Simplify with new contract.
        * solidbrush.c: Simplify with new contract.
        * texturebrush.c: Simplify with new contract.



Modified: trunk/libgdiplus/src/ChangeLog
===================================================================
--- trunk/libgdiplus/src/ChangeLog      2007-03-30 16:48:00 UTC (rev 75217)
+++ trunk/libgdiplus/src/ChangeLog      2007-03-30 17:03:24 UTC (rev 75218)
@@ -1,3 +1,14 @@
+2007-03-30  Sebastien Pouliot  <[EMAIL PROTECTED]> 
+
+       * brush.c: Change contract between GdipDeleteBrush and the destroy
+       function of the specialized brushes. The NULL check and the GdipFree
+       of the brush is now done centrally.
+       * hatchbrush.c: Simplify with new contract.
+       * lineargradientbrush.c: Simplify with new contract.
+       * pathgradientbrush.c: Simplify with new contract.
+       * solidbrush.c: Simplify with new contract.
+       * texturebrush.c: Simplify with new contract.
+
 2007-03-30  Sebastien Pouliot  <[EMAIL PROTECTED]>
 
        * pen.c: Update solid brush color (if used) when the pen color is 

Modified: trunk/libgdiplus/src/brush.c
===================================================================
--- trunk/libgdiplus/src/brush.c        2007-03-30 16:48:00 UTC (rev 75217)
+++ trunk/libgdiplus/src/brush.c        2007-03-30 17:03:24 UTC (rev 75218)
@@ -2,6 +2,7 @@
  * brush.c
  * 
  * Copyright (c) 2003 Alexandre Pigolkine
+ * Copyright (C) 2007 Novell, Inc. http://www.novell.com
  * 
  * Permission is hereby granted, free of charge, to any person obtaining a 
copy of this software 
  * and associated documentation files (the "Software"), to deal in the 
Software without restriction, 
@@ -72,10 +73,15 @@
 GpStatus 
 GdipDeleteBrush (GpBrush *brush)
 {
+       GpStatus status;
+
        if (!brush)
                return InvalidParameter;
 
-       return brush->vtable->destroy (brush);
+       status = brush->vtable->destroy (brush);
+       GdipFree (brush);
+
+       return status;
 }
 
 GpStatus

Modified: trunk/libgdiplus/src/hatchbrush.c
===================================================================
--- trunk/libgdiplus/src/hatchbrush.c   2007-03-30 16:48:00 UTC (rev 75217)
+++ trunk/libgdiplus/src/hatchbrush.c   2007-03-30 17:03:24 UTC (rev 75218)
@@ -1,7 +1,7 @@
 /*
  * hatchbrush.c
  * 
- * Copyright (C) 2004,2006 Novell, Inc. http://www.novell.com
+ * Copyright (C) 2004,2006-2007 Novell, Inc. http://www.novell.com
  *
  * Permission is hereby granted, free of charge, to any person obtaining a 
copy of this software 
  * and associated documentation files (the "Software"), to deal in the 
Software without restriction, 
@@ -1312,20 +1312,15 @@
 GpStatus
 gdip_hatch_destroy (GpBrush *brush)
 {
-       GpHatch *hbr;
+       /* a. the NULL check for brush is done by the caller, GdipDeleteBrush */
+       /* b. brush itself is freed by the caller */
 
-       if (!brush)
-               return InvalidParameter;
+       GpHatch *hbr = (GpHatch *) brush;
 
-       hbr = (GpHatch *) brush;
-
        if (hbr->pattern) {
                cairo_pattern_destroy (hbr->pattern);
                hbr->pattern = NULL;
        }
-
-       GdipFree (brush);
-
        return Ok;
 }
 

Modified: trunk/libgdiplus/src/lineargradientbrush.c
===================================================================
--- trunk/libgdiplus/src/lineargradientbrush.c  2007-03-30 16:48:00 UTC (rev 
75217)
+++ trunk/libgdiplus/src/lineargradientbrush.c  2007-03-30 17:03:24 UTC (rev 
75218)
@@ -1,7 +1,7 @@
 /*
  * lineargradientbrush.c
  *
- * Copyright (C) Novell, Inc. 2003-2004.
+ * Copyright (C) 2003-2004,2007 Novell, Inc. http://www.novell.com
  *
  * Permission is hereby granted, free of charge, to any person obtaining a 
copy of this software 
  * and associated documentation files (the "Software"), to deal in the 
Software without restriction, 
@@ -171,13 +171,11 @@
 GpStatus
 gdip_linear_gradient_destroy (GpBrush *brush)
 {
-       GpLineGradient *linear;
+       /* a. the NULL check for brush is done by the caller, GdipDeleteBrush */
+       /* b. brush itself is freed by the caller */
 
-       if (!brush)
-               return InvalidParameter;
+       GpLineGradient *linear = (GpLineGradient *) brush;
 
-       linear = (GpLineGradient *) brush;
-
        if (linear->blend) {
                if (linear->blend->count > 0) {
                        GdipFree (linear->blend->factors);
@@ -201,8 +199,6 @@
                linear->pattern = NULL;
        }
 
-       GdipFree (linear);
-
        return Ok;
 }
 

Modified: trunk/libgdiplus/src/pathgradientbrush.c
===================================================================
--- trunk/libgdiplus/src/pathgradientbrush.c    2007-03-30 16:48:00 UTC (rev 
75217)
+++ trunk/libgdiplus/src/pathgradientbrush.c    2007-03-30 17:03:24 UTC (rev 
75218)
@@ -1,7 +1,7 @@
 /*
  * pathgradientbrush.c
  *
- * Copyright (C) Novell, Inc. 2003-2004.
+ * Copyright (C) 2003-2004,2007 Novell, Inc. http://www.novell.com
  *
  * Permission is hereby granted, free of charge, to any person obtaining a 
copy of this software 
  * and associated documentation files (the "Software"), to deal in the 
Software without restriction, 
@@ -185,13 +185,11 @@
 GpStatus
 gdip_pgrad_destroy (GpBrush *brush)
 {
-       GpPathGradient *pgbrush;
+       /* a. the NULL check for brush is done by the caller, GdipDeleteBrush */
+       /* b. brush itself is freed by the caller */
 
-       if (!brush)
-               return InvalidParameter;
+       GpPathGradient *pgbrush = (GpPathGradient *) brush;
 
-       pgbrush = (GpPathGradient *) brush;
-
        if (pgbrush->boundary) {
                GdipDeletePath (pgbrush->boundary);
                pgbrush->boundary = NULL;
@@ -225,7 +223,6 @@
                pgbrush->presetColors = NULL;
        }
 
-       GdipFree (pgbrush);
        return Ok;
 }
 

Modified: trunk/libgdiplus/src/solidbrush.c
===================================================================
--- trunk/libgdiplus/src/solidbrush.c   2007-03-30 16:48:00 UTC (rev 75217)
+++ trunk/libgdiplus/src/solidbrush.c   2007-03-30 17:03:24 UTC (rev 75218)
@@ -2,6 +2,7 @@
  * solidbrush.c
  * 
  * Copyright (c) 2003 Alexandre Pigolkine
+ * Copyright (C) 2007 Novell, Inc. http://www.novell.com
  * 
  * Permission is hereby granted, free of charge, to any person obtaining a 
copy of this software 
  * and associated documentation files (the "Software"), to deal in the 
Software without restriction, 
@@ -122,10 +123,8 @@
 GpStatus
 gdip_solidfill_destroy (GpBrush *brush)
 {
-       /* the NULL check for brush is done by the caller, GdipDeleteBrush */
-
-       GdipFree (brush);
-
+       /* a. the NULL check for brush is done by the caller, GdipDeleteBrush */
+       /* b. brush itself is freed by the caller */
        return Ok;
 }
 

Modified: trunk/libgdiplus/src/texturebrush.c
===================================================================
--- trunk/libgdiplus/src/texturebrush.c 2007-03-30 16:48:00 UTC (rev 75217)
+++ trunk/libgdiplus/src/texturebrush.c 2007-03-30 17:03:24 UTC (rev 75218)
@@ -1,7 +1,7 @@
 /*
  * texturebrush.c
  *
- * Copyright (C) 2003,2006 Novell, Inc. http://www.novell.com
+ * Copyright (C) 2003,2006-2007 Novell, Inc. http://www.novell.com
  *
  * Permission is hereby granted, free of charge, to any person obtaining a 
copy of this software 
  * and associated documentation files (the "Software"), to deal in the 
Software without restriction, 
@@ -568,14 +568,11 @@
 GpStatus
 gdip_texture_destroy (GpBrush *brush)
 {
-       GpTexture *texture;
+       /* a. the NULL check for brush is done by the caller, GdipDeleteBrush */
+       /* b. brush itself is freed by the caller */
 
-       if (brush == NULL) {
-               return InvalidParameter;
-       }
+       GpTexture *texture = (GpTexture *) brush;
 
-       texture = (GpTexture *) brush;
-
        if (texture->pattern) {
                cairo_pattern_destroy (texture->pattern);
                texture->pattern = NULL;
@@ -586,8 +583,6 @@
                texture->image = NULL;
        }
 
-       GdipFree (texture);
-
        return Ok;
 }
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to