summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorPeter Eisentraut2022-06-16 19:50:56 +0000
committerPeter Eisentraut2022-07-03 09:47:15 +0000
commit02c408e21a6e78ff246ea7a1beb4669634fa9c4c (patch)
tree7e4cf03f3de7e32af266b739e12c6600d871ed45 /contrib
parent098c703d308fa88dc9e3f9f623ca023ce4717794 (diff)
Remove redundant null pointer checks before free()
Per applicable standards, free() with a null pointer is a no-op. Systems that don't observe that are ancient and no longer relevant. Some PostgreSQL code already required this behavior, so this change does not introduce any new requirements, just makes the code more consistent. Discussion: https://www.postgresql.org/message-id/flat/dac5d2d0-98f5-94d9-8e69-46da2413593d%40enterprisedb.com
Diffstat (limited to 'contrib')
-rw-r--r--contrib/pg_stat_statements/pg_stat_statements.c12
-rw-r--r--contrib/uuid-ossp/uuid-ossp.c6
2 files changed, 6 insertions, 12 deletions
diff --git a/contrib/pg_stat_statements/pg_stat_statements.c b/contrib/pg_stat_statements/pg_stat_statements.c
index 768cedd91a7..4acfddcdb87 100644
--- a/contrib/pg_stat_statements/pg_stat_statements.c
+++ b/contrib/pg_stat_statements/pg_stat_statements.c
@@ -809,8 +809,7 @@ error:
(errcode_for_file_access(),
errmsg("could not write file \"%s\": %m",
PGSS_DUMP_FILE ".tmp")));
- if (qbuffer)
- free(qbuffer);
+ free(qbuffer);
if (file)
FreeFile(file);
unlink(PGSS_DUMP_FILE ".tmp");
@@ -1657,8 +1656,7 @@ pg_stat_statements_internal(FunctionCallInfo fcinfo,
pgss->extent != extent ||
pgss->gc_count != gc_count)
{
- if (qbuffer)
- free(qbuffer);
+ free(qbuffer);
qbuffer = qtext_load_file(&qbuffer_size);
}
}
@@ -1842,8 +1840,7 @@ pg_stat_statements_internal(FunctionCallInfo fcinfo,
LWLockRelease(pgss->lock);
- if (qbuffer)
- free(qbuffer);
+ free(qbuffer);
}
/* Number of output arguments (columns) for pg_stat_statements_info */
@@ -2446,8 +2443,7 @@ gc_fail:
/* clean up resources */
if (qfile)
FreeFile(qfile);
- if (qbuffer)
- free(qbuffer);
+ free(qbuffer);
/*
* Since the contents of the external file are now uncertain, mark all
diff --git a/contrib/uuid-ossp/uuid-ossp.c b/contrib/uuid-ossp/uuid-ossp.c
index 7c0fb812fd7..b868812358d 100644
--- a/contrib/uuid-ossp/uuid-ossp.c
+++ b/contrib/uuid-ossp/uuid-ossp.c
@@ -292,8 +292,7 @@ uuid_generate_internal(int v, unsigned char *ns, const char *ptr, int len)
if (ptr && len <= 36)
strcpy(strbuf + (36 - len), ptr);
}
- if (str)
- free(str);
+ free(str);
}
if (status != uuid_s_ok)
@@ -366,8 +365,7 @@ uuid_generate_internal(int v, unsigned char *ns, const char *ptr, int len)
if (status == uuid_s_ok)
strlcpy(strbuf, str, 37);
- if (str)
- free(str);
+ free(str);
if (status != uuid_s_ok)
ereport(ERROR,