aboutsummaryrefslogtreecommitdiff
path: root/src/bin/psql/copy.c
diff options
context:
space:
mode:
authorNeil Conway <neilc@samurai.com>2004-01-24 19:38:49 +0000
committerNeil Conway <neilc@samurai.com>2004-01-24 19:38:49 +0000
commit610d33c1949005e9658863441f31083f9f3ceb9b (patch)
tree861eb9dfec8dc43b4f5716f48aa52d4468128a90 /src/bin/psql/copy.c
parentcb3dc829f639801219aab4ec35e53ef924ce75c5 (diff)
downloadpostgresql-610d33c1949005e9658863441f31083f9f3ceb9b.tar.gz
postgresql-610d33c1949005e9658863441f31083f9f3ceb9b.zip
This patch makes some of the memory manipulation performed by psql a
little more sane. Some parts of the code was using a static function xmalloc() that did safe memory allocation (where "safe" means "bail out on OOM"), but most of it was just invoking calloc() or malloc() directly. Now almost everything invokes xmalloc() or xcalloc().
Diffstat (limited to 'src/bin/psql/copy.c')
-rw-r--r--src/bin/psql/copy.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/src/bin/psql/copy.c b/src/bin/psql/copy.c
index e852dd5b7a1..534efe0ca2b 100644
--- a/src/bin/psql/copy.c
+++ b/src/bin/psql/copy.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.37 2004/01/20 23:48:56 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/copy.c,v 1.38 2004/01/24 19:38:49 neilc Exp $
*/
#include "postgres_fe.h"
#include "copy.h"
@@ -83,12 +83,7 @@ xstrcat(char **var, const char *more)
{
char *newvar;
- newvar = (char *) malloc(strlen(*var) + strlen(more) + 1);
- if (!newvar)
- {
- psql_error("out of memory\n");
- exit(EXIT_FAILURE);
- }
+ newvar = xmalloc(strlen(*var) + strlen(more) + 1);
strcpy(newvar, *var);
strcat(newvar, more);
free(*var);
@@ -112,11 +107,7 @@ parse_slash_copy(const char *args)
return NULL;
}
- if (!(result = calloc(1, sizeof(struct copy_options))))
- {
- psql_error("out of memory\n");
- exit(EXIT_FAILURE);
- }
+ result = xcalloc(1, sizeof(struct copy_options));
token = strtokx(line, whitespace, ".,()", "\"",
0, false, pset.encoding);