Remove useless checks for NULL before freeing

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;
type T;
@@
+ free ((T) E);
+ E = NULL;
- if (unlikely (E != NULL)) {
-   free((T) E);
(
-   E = NULL;
|
-   E = 0;
)
   ...
- }

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

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

Reviewed-by: Brian Paul <brianp@vmware.com>
This commit is contained in:
Matt Turner
2012-09-03 20:24:35 -07:00
parent a9e8054fff
commit 5067506ea6
46 changed files with 88 additions and 184 deletions

View File

@@ -1158,11 +1158,9 @@ _mesa_free_context_data( struct gl_context *ctx )
_mesa_free_errors_data(ctx);
if (ctx->Extensions.String)
free((void *) ctx->Extensions.String);
free((void *)ctx->Extensions.String);
if (ctx->VersionString)
free(ctx->VersionString);
free(ctx->VersionString);
/* unbind the context if it's currently bound */
if (ctx == _mesa_get_current_context()) {