Fix failure to set identity transform in pixman.
authorEric Anholt <eric@anholt.net>
Mon, 20 Aug 2007 19:58:47 +0000 (12:58 -0700)
committerEric Anholt <eric@anholt.net>
Mon, 20 Aug 2007 20:02:54 +0000 (13:02 -0700)
While here, optimize out a free/malloc in the case where a transform
existed previously and the new transform is non-identity.

pixman/pixman-image.c

index 2cbf88c..32ffaee 100644 (file)
@@ -403,25 +403,17 @@ pixman_image_set_transform (pixman_image_t           *image,
 
     if (memcmp (&id, transform, sizeof (pixman_transform_t)) == 0)
     {
-       transform = NULL;
+       free(common->transform);
+       common->transform = NULL;
        return TRUE;
     }
     
-    if (common->transform)
-       free (common->transform);
-
-    if (transform)
-    {
+    if (common->transform == NULL)
        common->transform = malloc (sizeof (pixman_transform_t));
-       if (!common->transform)
-           return FALSE;
+    if (common->transform == NULL)
+       return FALSE;
 
-       *common->transform = *transform;
-    }
-    else
-    {
-       common->transform = NULL;
-    }
+    memcpy(common->transform, transform, sizeof(pixman_transform_t));
 
     return TRUE;
 }