From 90d76525c5cc2f3f4781351a1d99be839dfa2874 Mon Sep 17 00:00:00 2001 From: Neil Conway Date: Sat, 3 Mar 2007 19:32:55 +0000 Subject: 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. --- src/backend/libpq/pqcomm.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'src/backend/libpq') diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c index a8f40249c9..d9439e7fd9 100644 --- a/src/backend/libpq/pqcomm.c +++ b/src/backend/libpq/pqcomm.c @@ -30,7 +30,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/libpq/pqcomm.c,v 1.190 2007/02/13 19:18:53 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/libpq/pqcomm.c,v 1.191 2007/03/03 19:32:54 neilc Exp $ * *------------------------------------------------------------------------- */ @@ -860,10 +860,7 @@ pq_getstring(StringInfo s) { int i; - /* Reset string to empty */ - s->len = 0; - s->data[0] = '\0'; - s->cursor = 0; + resetStringInfo(s); /* Read until we get the terminating '\0' */ for (;;) @@ -915,10 +912,7 @@ pq_getmessage(StringInfo s, int maxlen) { int32 len; - /* Reset message buffer to empty */ - s->len = 0; - s->data[0] = '\0'; - s->cursor = 0; + resetStringInfo(s); /* Read message length word */ if (pq_getbytes((char *) &len, 4) == EOF) -- cgit v1.2.1