aboutsummaryrefslogtreecommitdiff
path: root/src/bin/psql/common.h
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/common.h
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/common.h')
-rw-r--r--src/bin/psql/common.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/bin/psql/common.h b/src/bin/psql/common.h
index db8037b1ed5..05e29967ba0 100644
--- a/src/bin/psql/common.h
+++ b/src/bin/psql/common.h
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.32 2004/01/09 21:12:20 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.33 2004/01/24 19:38:49 neilc Exp $
*/
#ifndef COMMON_H
#define COMMON_H
@@ -20,7 +20,15 @@
#define psql_assert(p)
#endif
+/*
+ * Safer versions of some standard C library functions. If an
+ * out-of-memory condition occurs, these functions will bail out
+ * safely; therefore, their return value is guaranteed to be non-NULL.
+ */
extern char *xstrdup(const char *string);
+extern void *xmalloc(size_t size);
+extern void *xmalloc_zero(size_t size);
+extern void *xcalloc(size_t nmemb, size_t size);
extern bool setQFout(const char *fname);