Remove useless checks for NULL before freeing
authorAndrea Canciani <ranma42@gmail.com>
Thu, 3 Nov 2011 09:21:41 +0000 (10:21 +0100)
committerAndrea Canciani <ranma42@gmail.com>
Wed, 9 Nov 2011 08:17:00 +0000 (09:17 +0100)
This patch has been generated by the following Coccinelle semantic patch:

// Remove useless checks for NULL before freeing
//
// free (NULL) is a no-op, so there is no need to avoid it

@@
expression E;
@@
+ free (E);
+ E = NULL;
- if (unlikely (E != NULL)) {
-   free(E);
(
-   E = NULL;
|
-   E = 0;
)
   ...
- }

@@
expression E;
@@
+ free (E);
- if (unlikely (E != NULL)) {
-   free (E);
- }

pixman/pixman-image.c
pixman/pixman-region.c

index 09d7cbc..913853c 100644 (file)
@@ -145,11 +145,8 @@ _pixman_image_fini (pixman_image_t *image)
 
        pixman_region32_fini (&common->clip_region);
 
-       if (common->transform)
-           free (common->transform);
-
-       if (common->filter_params)
-           free (common->filter_params);
+       free (common->transform);
+       free (common->filter_params);
 
        if (common->alpha_map)
            pixman_image_unref ((pixman_image_t *)common->alpha_map);
index 47beb52..80219c6 100644 (file)
@@ -828,8 +828,7 @@ pixman_op (region_type_t *  new_reg,               /* Place to store result
     {
         if (!pixman_rect_alloc (new_reg, new_size))
         {
-            if (old_data)
-               free (old_data);
+            free (old_data);
             return FALSE;
        }
     }
@@ -1005,8 +1004,7 @@ pixman_op (region_type_t *  new_reg,               /* Place to store result
         APPEND_REGIONS (new_reg, r2_band_end, r2_end);
     }
 
-    if (old_data)
-       free (old_data);
+    free (old_data);
 
     if (!(numRects = new_reg->data->numRects))
     {
@@ -1027,8 +1025,7 @@ pixman_op (region_type_t *  new_reg,               /* Place to store result
     return TRUE;
 
 bail:
-    if (old_data)
-       free (old_data);
+    free (old_data);
 
     return pixman_break (new_reg);
 }