mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +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:
@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user