aboutsummaryrefslogtreecommitdiff
path: root/src/bin/psql/stringutils.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/stringutils.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/stringutils.c')
-rw-r--r--src/bin/psql/stringutils.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/bin/psql/stringutils.c b/src/bin/psql/stringutils.c
index c90abb2cdd6..eda7837d806 100644
--- a/src/bin/psql/stringutils.c
+++ b/src/bin/psql/stringutils.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/stringutils.c,v 1.36 2003/12/01 22:14:40 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/stringutils.c,v 1.37 2004/01/24 19:38:49 neilc Exp $
*/
#include "postgres_fe.h"
@@ -77,9 +77,7 @@ strtokx(const char *s,
* tokens. 2X the space is a gross overestimate, but it's
* unlikely that this code will be used on huge strings anyway.
*/
- storage = (char *) malloc(2 * strlen(s) + 1);
- if (!storage)
- return NULL; /* really "out of memory" */
+ storage = xmalloc(2 * strlen(s) + 1);
strcpy(storage, s);
string = storage;
}