[fusion-commits] compiz mirror: Changes to 'master' (2cf83ff3d7c26da4ffdd96fb0a76cad2fecd0e4f)

compiz at server.beryl-project.org compiz at server.beryl-project.org
Wed Jul 25 01:47:06 CEST 2007


New commits:
commit 2cf83ff3d7c26da4ffdd96fb0a76cad2fecd0e4f
Author: David Reveman <davidr at novell.com>
Date:   Tue Jul 24 19:44:41 2007 -0400

    Check for memory errors.

commit 4cb6a481da9284241858d5da327adc3550709adf
Author: David Reveman <davidr at novell.com>
Date:   Tue Jul 24 19:42:36 2007 -0400

    Clean up.


 plugins/scale.c |   27 +++++++++++++++++++--------
 1 files changed, 19 insertions(+), 8 deletions(-)


Modified: compiz/plugins/scale.c
===================================================================
--- compiz/plugins/scale.c
+++ compiz/plugins/scale.c
@@ -489,7 +489,7 @@ layoutSlotsForArea (CompScreen * s,
     }
 }
 
-static SlotArea* 
+static SlotArea *
 getSlotAreas (CompScreen *s)
 {
     int        i;
@@ -499,10 +499,18 @@ getSlotAreas (CompScreen *s)
     int        left;
     SlotArea   *slotAreas;
 
-    SCALE_SCREEN(s);
+    SCALE_SCREEN (s);
+
+    size = malloc (s->nOutputDev * sizeof (int));
+    if (!size)
+	return NULL;
 
-    size      = malloc (s->nOutputDev * sizeof (int));
     slotAreas = malloc (s->nOutputDev * sizeof (SlotArea));
+    if (!slotAreas)
+    {
+	free (size);
+        return NULL;
+    }
 
     left = ss->nWindows;
 
@@ -512,7 +520,7 @@ getSlotAreas (CompScreen *s)
 	workArea = s->outputDev[i].workArea;
 
 	size[i] = workArea.width * workArea.height;
-	sum     += size[i];
+	sum += size[i];
 
 	slotAreas[i].nWindows = 0;
 	slotAreas[i].workArea = workArea;
@@ -524,9 +532,9 @@ getSlotAreas (CompScreen *s)
     for (i = 0; i < s->nOutputDev && left; i++)
     {
 	/* fill the areas with windows */
-	int nw = floor(size[i] / sizePerWindow);
-	nw = MIN (nw,left);
+	int nw = floor (size[i] / sizePerWindow);
 
+	nw = MIN (nw, left);
 	size[i] -= nw * sizePerWindow;
 	slotAreas[i].nWindows = nw;
 	left -= nw;
@@ -535,22 +543,25 @@ getSlotAreas (CompScreen *s)
     /* add left windows to output devices with the biggest free space */
     while (left > 0)
     {
-	int num = 0;
+	int   num = 0;
 	float big = 0;
 
 	for (i = 0; i < s->nOutputDev; i++)
+	{
 	    if (size[i] > big)
 	    {
 		num = i;
 		big = size[i];
 	    }
+	}
 
 	size[num] -= sizePerWindow;
 	slotAreas[num].nWindows++;
 	left--;
     }
 
-    free(size);
+    free (size);
+
     return slotAreas;
 }
 


More information about the commits mailing list