diff options
| author | Tom Lane | 2012-10-02 19:35:10 +0000 |
|---|---|---|
| committer | Tom Lane | 2012-10-02 19:35:48 +0000 |
| commit | a563d941803535dbd27d4191fe7729497b7fdf31 (patch) | |
| tree | 79048d522a1b35451381970fcec821e18f3cf0ab /src/bin/pg_basebackup | |
| parent | 779f80b75d448d61cf3388645505c9fd81000bb2 (diff) | |
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.)
Diffstat (limited to 'src/bin/pg_basebackup')
| -rw-r--r-- | src/bin/pg_basebackup/pg_basebackup.c | 14 | ||||
| -rw-r--r-- | src/bin/pg_basebackup/pg_receivexlog.c | 8 | ||||
| -rw-r--r-- | src/bin/pg_basebackup/receivelog.c | 2 | ||||
| -rw-r--r-- | src/bin/pg_basebackup/streamutil.c | 10 | ||||
| -rw-r--r-- | src/bin/pg_basebackup/streamutil.h | 6 |
5 files changed, 20 insertions, 20 deletions
diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c index ad994f4fa2b..4f22116c3ee 100644 --- a/src/bin/pg_basebackup/pg_basebackup.c +++ b/src/bin/pg_basebackup/pg_basebackup.c @@ -263,7 +263,7 @@ StartLogStreamer(char *startpos, uint32 timeline, char *sysidentifier) uint32 hi, lo; - param = xmalloc0(sizeof(logstreamer_param)); + param = pg_malloc0(sizeof(logstreamer_param)); param->timeline = timeline; param->sysidentifier = sysidentifier; @@ -977,7 +977,7 @@ BaseBackup(void) progname, PQntuples(res), PQnfields(res), 1, 3); disconnect_and_exit(1); } - sysidentifier = strdup(PQgetvalue(res, 0, 0)); + sysidentifier = pg_strdup(PQgetvalue(res, 0, 0)); timeline = atoi(PQgetvalue(res, 0, 1)); PQclear(res); @@ -1286,7 +1286,7 @@ main(int argc, char **argv) switch (c) { case 'D': - basedir = xstrdup(optarg); + basedir = pg_strdup(optarg); break; case 'F': if (strcmp(optarg, "p") == 0 || strcmp(optarg, "plain") == 0) @@ -1338,7 +1338,7 @@ main(int argc, char **argv) } break; case 'l': - label = xstrdup(optarg); + label = pg_strdup(optarg); break; case 'z': #ifdef HAVE_LIBZ @@ -1369,13 +1369,13 @@ main(int argc, char **argv) } break; case 'h': - dbhost = xstrdup(optarg); + dbhost = pg_strdup(optarg); break; case 'p': - dbport = xstrdup(optarg); + dbport = pg_strdup(optarg); break; case 'U': - dbuser = xstrdup(optarg); + dbuser = pg_strdup(optarg); break; case 'w': dbgetpassword = -1; diff --git a/src/bin/pg_basebackup/pg_receivexlog.c b/src/bin/pg_basebackup/pg_receivexlog.c index 55c7bc692f0..843fc69294d 100644 --- a/src/bin/pg_basebackup/pg_receivexlog.c +++ b/src/bin/pg_basebackup/pg_receivexlog.c @@ -342,10 +342,10 @@ main(int argc, char **argv) switch (c) { case 'D': - basedir = xstrdup(optarg); + basedir = pg_strdup(optarg); break; case 'h': - dbhost = xstrdup(optarg); + dbhost = pg_strdup(optarg); break; case 'p': if (atoi(optarg) <= 0) @@ -354,10 +354,10 @@ main(int argc, char **argv) progname, optarg); exit(1); } - dbport = xstrdup(optarg); + dbport = pg_strdup(optarg); break; case 'U': - dbuser = xstrdup(optarg); + dbuser = pg_strdup(optarg); break; case 'w': dbgetpassword = -1; diff --git a/src/bin/pg_basebackup/receivelog.c b/src/bin/pg_basebackup/receivelog.c index 1e09012bfc7..404ff917150 100644 --- a/src/bin/pg_basebackup/receivelog.c +++ b/src/bin/pg_basebackup/receivelog.c @@ -97,7 +97,7 @@ open_walfile(XLogRecPtr startpoint, uint32 timeline, char *basedir, } /* New, empty, file. So pad it to 16Mb with zeroes */ - zerobuf = xmalloc0(XLOG_BLCKSZ); + zerobuf = pg_malloc0(XLOG_BLCKSZ); for (bytes = 0; bytes < XLogSegSize; bytes += XLOG_BLCKSZ) { if (write(f, zerobuf, XLOG_BLCKSZ) != XLOG_BLCKSZ) diff --git a/src/bin/pg_basebackup/streamutil.c b/src/bin/pg_basebackup/streamutil.c index c32c5acb2b9..b6cc2a303e9 100644 --- a/src/bin/pg_basebackup/streamutil.c +++ b/src/bin/pg_basebackup/streamutil.c @@ -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"; diff --git a/src/bin/pg_basebackup/streamutil.h b/src/bin/pg_basebackup/streamutil.h index baba5eb04fb..fdf36418616 100644 --- a/src/bin/pg_basebackup/streamutil.h +++ b/src/bin/pg_basebackup/streamutil.h @@ -16,7 +16,7 @@ extern PGconn *conn; } -char *xstrdup(const char *s); -void *xmalloc0(int size); +extern char *pg_strdup(const char *s); +extern void *pg_malloc0(size_t size); -PGconn *GetConnection(void); +extern PGconn *GetConnection(void); |
