aboutsummaryrefslogtreecommitdiff
path: root/src/backend/lib/stringinfo.c
diff options
context:
space:
mode:
authorNeil Conway <neilc@samurai.com>2007-03-03 19:32:55 +0000
committerNeil Conway <neilc@samurai.com>2007-03-03 19:32:55 +0000
commit90d76525c5cc2f3f4781351a1d99be839dfa2874 (patch)
tree75ee2db58298898533663d779d711879c43edb8d /src/backend/lib/stringinfo.c
parent053981f4054f6dfcda0ce65566605b49ca366a97 (diff)
downloadpostgresql-90d76525c5cc2f3f4781351a1d99be839dfa2874.tar.gz
postgresql-90d76525c5cc2f3f4781351a1d99be839dfa2874.zip
Add resetStringInfo(), which clears the content of a StringInfo, and
fixup various places in the tree that were clearing a StringInfo by hand. Making this function a part of the API simplifies client code slightly, and avoids needlessly peeking inside the StringInfo interface.
Diffstat (limited to 'src/backend/lib/stringinfo.c')
-rw-r--r--src/backend/lib/stringinfo.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/backend/lib/stringinfo.c b/src/backend/lib/stringinfo.c
index 826212d0aad..b0854ddc43b 100644
--- a/src/backend/lib/stringinfo.c
+++ b/src/backend/lib/stringinfo.c
@@ -9,7 +9,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/lib/stringinfo.c,v 1.44 2007/01/05 22:19:29 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/lib/stringinfo.c,v 1.45 2007/03/03 19:32:54 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -49,8 +49,20 @@ initStringInfo(StringInfo str)
str->data = (char *) palloc(size);
str->maxlen = size;
- str->len = 0;
+ resetStringInfo(str);
+}
+
+/*
+ * resetStringInfo
+ *
+ * Reset the StringInfo: the data buffer remains valid, but its
+ * previous content, if any, is cleared.
+ */
+void
+resetStringInfo(StringInfo str)
+{
str->data[0] = '\0';
+ str->len = 0;
str->cursor = 0;
}