aboutsummaryrefslogtreecommitdiff
path: root/src/bin/scripts/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/scripts/common.c')
-rw-r--r--src/bin/scripts/common.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/bin/scripts/common.c b/src/bin/scripts/common.c
index b1ca5bb71d5..ea1fa0f2762 100644
--- a/src/bin/scripts/common.c
+++ b/src/bin/scripts/common.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.31 2008/01/01 19:45:56 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.32 2008/05/12 22:59:58 alvherre Exp $
*
*-------------------------------------------------------------------------
*/
@@ -229,6 +229,27 @@ executeMaintenanceCommand(PGconn *conn, const char *query, bool echo)
return r;
}
+/*
+ * "Safe" wrapper around strdup(). Pulled from psql/common.c
+ */
+char *
+pg_strdup(const char *string)
+{
+ char *tmp;
+
+ if (!string)
+ {
+ fprintf(stderr, _("pg_strdup: cannot duplicate null pointer (internal error)\n"));
+ exit(EXIT_FAILURE);
+ }
+ tmp = strdup(string);
+ if (!tmp)
+ {
+ fprintf(stderr, _("out of memory\n"));
+ exit(EXIT_FAILURE);
+ }
+ return tmp;
+}
/*
* Check yes/no answer in a localized way. 1=yes, 0=no, -1=neither.
@@ -274,7 +295,6 @@ yesno_prompt(const char *question)
}
}
-
/*
* SetCancelConn
*