mirror of
https://github.com/postgres/postgres.git
synced 2025-08-22 21:53:06 +03:00
Standardize naming of malloc/realloc/strdup wrapper functions.
We had a number of variants on the theme of "malloc or die", with the majority named like "pg_malloc", but by no means all. Standardize on the names pg_malloc, pg_malloc0, pg_realloc, pg_strdup. Get rid of pg_calloc entirely in favor of using pg_malloc0. This is an essentially cosmetic change, so no back-patch. (I did find a couple of places where psql and pg_dump were using plain malloc or strdup instead of the pg_ versions, but they don't look significant enough to bother back-patching.)
This commit is contained in:
@@ -32,11 +32,11 @@ static char *dbpassword = NULL;
|
||||
PGconn *conn = NULL;
|
||||
|
||||
/*
|
||||
* strdup() and malloc() replacements that prints an error and exits
|
||||
* strdup() and malloc() replacements that print an error and exit
|
||||
* if something goes wrong. Can never return NULL.
|
||||
*/
|
||||
char *
|
||||
xstrdup(const char *s)
|
||||
pg_strdup(const char *s)
|
||||
{
|
||||
char *result;
|
||||
|
||||
@@ -50,7 +50,7 @@ xstrdup(const char *s)
|
||||
}
|
||||
|
||||
void *
|
||||
xmalloc0(int size)
|
||||
pg_malloc0(size_t size)
|
||||
{
|
||||
void *result;
|
||||
|
||||
@@ -89,8 +89,8 @@ GetConnection(void)
|
||||
if (dbport)
|
||||
argcount++;
|
||||
|
||||
keywords = xmalloc0((argcount + 1) * sizeof(*keywords));
|
||||
values = xmalloc0((argcount + 1) * sizeof(*values));
|
||||
keywords = pg_malloc0((argcount + 1) * sizeof(*keywords));
|
||||
values = pg_malloc0((argcount + 1) * sizeof(*values));
|
||||
|
||||
keywords[0] = "dbname";
|
||||
values[0] = "replication";
|
||||
|
Reference in New Issue
Block a user