mirror of
https://github.com/postgres/postgres.git
synced 2025-04-25 21:42:33 +03:00
Remove redundant null pointer checks before pg_free()
These are especially useless because the whole point of pg_free() was to do that very check before calling free(). pg_free() could be removed altogether, but I'm keeping it here to keep the API consistent. Discussion: https://www.postgresql.org/message-id/flat/dac5d2d0-98f5-94d9-8e69-46da2413593d%40enterprisedb.com
This commit is contained in:
parent
e2bc242833
commit
098c703d30
@ -500,7 +500,6 @@ dir_close(Walfile f, WalCloseMethod method)
|
||||
|
||||
pg_free(df->pathname);
|
||||
pg_free(df->fullpath);
|
||||
if (df->temp_suffix)
|
||||
pg_free(df->temp_suffix);
|
||||
pg_free(df);
|
||||
|
||||
|
@ -130,13 +130,10 @@ parallel_exec_prog(const char *log_file, const char *opt_log_file,
|
||||
new_arg = exec_thread_args[parallel_jobs - 1];
|
||||
|
||||
/* Can only pass one pointer into the function, so use a struct */
|
||||
if (new_arg->log_file)
|
||||
pg_free(new_arg->log_file);
|
||||
new_arg->log_file = pg_strdup(log_file);
|
||||
if (new_arg->opt_log_file)
|
||||
pg_free(new_arg->opt_log_file);
|
||||
new_arg->opt_log_file = opt_log_file ? pg_strdup(opt_log_file) : NULL;
|
||||
if (new_arg->cmd)
|
||||
pg_free(new_arg->cmd);
|
||||
new_arg->cmd = pg_strdup(cmd);
|
||||
|
||||
@ -243,13 +240,10 @@ parallel_transfer_all_new_dbs(DbInfoArr *old_db_arr, DbInfoArr *new_db_arr,
|
||||
/* Can only pass one pointer into the function, so use a struct */
|
||||
new_arg->old_db_arr = old_db_arr;
|
||||
new_arg->new_db_arr = new_db_arr;
|
||||
if (new_arg->old_pgdata)
|
||||
pg_free(new_arg->old_pgdata);
|
||||
new_arg->old_pgdata = pg_strdup(old_pgdata);
|
||||
if (new_arg->new_pgdata)
|
||||
pg_free(new_arg->new_pgdata);
|
||||
new_arg->new_pgdata = pg_strdup(new_pgdata);
|
||||
if (new_arg->old_tablespace)
|
||||
pg_free(new_arg->old_tablespace);
|
||||
new_arg->old_tablespace = old_tablespace ? pg_strdup(old_tablespace) : NULL;
|
||||
|
||||
|
@ -5475,11 +5475,9 @@ static void
|
||||
free_command(Command *command)
|
||||
{
|
||||
termPQExpBuffer(&command->lines);
|
||||
if (command->first_line)
|
||||
pg_free(command->first_line);
|
||||
for (int i = 0; i < command->argc; i++)
|
||||
pg_free(command->argv[i]);
|
||||
if (command->varprefix)
|
||||
pg_free(command->varprefix);
|
||||
|
||||
/*
|
||||
@ -6637,7 +6635,6 @@ main(int argc, char **argv)
|
||||
is_init_mode = true;
|
||||
break;
|
||||
case 'I':
|
||||
if (initialize_steps)
|
||||
pg_free(initialize_steps);
|
||||
initialize_steps = pg_strdup(optarg);
|
||||
checkInitSteps(initialize_steps);
|
||||
|
@ -3492,7 +3492,6 @@ do_connect(enum trivalue reuse_previous_specification,
|
||||
} /* end retry loop */
|
||||
|
||||
/* Release locally allocated data, whether we succeeded or not */
|
||||
if (password)
|
||||
pg_free(password);
|
||||
if (cinfo)
|
||||
PQconninfoFree(cinfo);
|
||||
|
@ -255,7 +255,6 @@ SetVariable(VariableSpace space, const char *name, const char *value)
|
||||
|
||||
if (confirmed)
|
||||
{
|
||||
if (current->value)
|
||||
pg_free(current->value);
|
||||
current->value = new_value;
|
||||
|
||||
@ -272,7 +271,7 @@ SetVariable(VariableSpace space, const char *name, const char *value)
|
||||
free(current);
|
||||
}
|
||||
}
|
||||
else if (new_value)
|
||||
else
|
||||
pg_free(new_value); /* current->value is left unchanged */
|
||||
|
||||
return confirmed;
|
||||
|
Loading…
x
Reference in New Issue
Block a user