aboutsummaryrefslogtreecommitdiff
path: root/src/bin/psql/mainloop.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/mainloop.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/mainloop.c')
-rw-r--r--src/bin/psql/mainloop.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/src/bin/psql/mainloop.c b/src/bin/psql/mainloop.c
index 9a6448396b4..d59261fa2bc 100644
--- a/src/bin/psql/mainloop.c
+++ b/src/bin/psql/mainloop.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/mainloop.c,v 1.59 2004/01/21 22:05:44 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/mainloop.c,v 1.60 2004/01/24 19:38:49 neilc Exp $
*/
#include "postgres_fe.h"
#include "mainloop.h"
@@ -332,13 +332,7 @@ MainLoop(FILE *source)
/* It is a variable, perform substitution */
out_length = strlen(value);
- new = malloc(len + out_length - in_length + 1);
- if (!new)
- {
- psql_error("out of memory\n");
- exit(EXIT_FAILURE);
- }
-
+ new = xmalloc(len + out_length - in_length + 1);
sprintf(new, "%.*s%s%s", i, line, value,
&line[i + thislen + in_length]);