1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-29 23:43:17 +03:00

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.
This commit is contained in:
Neil Conway
2007-03-03 19:32:55 +00:00
parent 053981f405
commit 90d76525c5
11 changed files with 57 additions and 69 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/rowtypes.c,v 1.18 2007/01/05 22:19:42 momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/rowtypes.c,v 1.19 2007/03/03 19:32:55 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -168,8 +168,7 @@ record_in(PG_FUNCTION_ARGS)
/* Extract string for this column */
bool inquote = false;
buf.len = 0;
buf.data[0] = '\0';
resetStringInfo(&buf);
while (inquote || !(*ptr == ',' || *ptr == ')'))
{
char ch = *ptr++;

View File

@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.33 2007/03/01 14:52:04 petere Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.34 2007/03/03 19:32:55 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -835,8 +835,7 @@ xml_init(void)
else
{
/* Reset pre-existing buffer to empty */
xml_err_buf->data[0] = '\0';
xml_err_buf->len = 0;
resetStringInfo(xml_err_buf);
}
/* Now that xml_err_buf exists, safe to call xml_errorHandler */
xmlSetGenericErrorFunc(NULL, xml_errorHandler);
@@ -1197,8 +1196,7 @@ xml_ereport(int level, int sqlcode,
if (xml_err_buf->len > 0)
{
detail = pstrdup(xml_err_buf->data);
xml_err_buf->data[0] = '\0';
xml_err_buf->len = 0;
resetStringInfo(xml_err_buf);
}
else
detail = NULL;