aboutsummaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/pg_backup_db.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/pg_dump/pg_backup_db.c')
-rw-r--r--src/bin/pg_dump/pg_backup_db.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/src/bin/pg_dump/pg_backup_db.c b/src/bin/pg_dump/pg_backup_db.c
index 600728d1985..a58eb2da701 100644
--- a/src/bin/pg_dump/pg_backup_db.c
+++ b/src/bin/pg_dump/pg_backup_db.c
@@ -11,6 +11,7 @@
*/
#include "pg_backup_db.h"
+#include "common.h"
#include "dumputils.h"
#include <unistd.h>
@@ -55,7 +56,7 @@ _check_database_version(ArchiveHandle *AH)
remoteversion = _parse_version(AH, remoteversion_str);
- AH->public.remoteVersionStr = strdup(remoteversion_str);
+ AH->public.remoteVersionStr = pg_strdup(remoteversion_str);
AH->public.remoteVersion = remoteversion;
if (!AH->archiveRemoteVersion)
AH->archiveRemoteVersion = AH->public.remoteVersionStr;
@@ -150,11 +151,8 @@ _connectDB(ArchiveHandle *AH, const char *reqdb, const char *requser)
do
{
#define PARAMS_ARRAY_SIZE 7
- const char **keywords = malloc(PARAMS_ARRAY_SIZE * sizeof(*keywords));
- const char **values = malloc(PARAMS_ARRAY_SIZE * sizeof(*values));
-
- if (!keywords || !values)
- die_horribly(AH, modulename, "out of memory\n");
+ const char **keywords = pg_malloc(PARAMS_ARRAY_SIZE * sizeof(*keywords));
+ const char **values = pg_malloc(PARAMS_ARRAY_SIZE * sizeof(*values));
keywords[0] = "host";
values[0] = PQhost(AH->connection);
@@ -257,11 +255,8 @@ ConnectDatabase(Archive *AHX,
do
{
#define PARAMS_ARRAY_SIZE 7
- const char **keywords = malloc(PARAMS_ARRAY_SIZE * sizeof(*keywords));
- const char **values = malloc(PARAMS_ARRAY_SIZE * sizeof(*values));
-
- if (!keywords || !values)
- die_horribly(AH, modulename, "out of memory\n");
+ const char **keywords = pg_malloc(PARAMS_ARRAY_SIZE * sizeof(*keywords));
+ const char **values = pg_malloc(PARAMS_ARRAY_SIZE * sizeof(*values));
keywords[0] = "host";
values[0] = pghost;
@@ -397,10 +392,8 @@ ExecuteSqlCommandBuf(ArchiveHandle *AH, const char *buf, size_t bufLen)
ExecuteSqlCommand(AH, buf, "could not execute query");
else
{
- char *str = (char *) malloc(bufLen + 1);
+ char *str = (char *) pg_malloc(bufLen + 1);
- if (!str)
- die_horribly(AH, modulename, "out of memory\n");
memcpy(str, buf, bufLen);
str[bufLen] = '\0';
ExecuteSqlCommand(AH, str, "could not execute query");