resetStringInfo

From: Neil Conway <neilc(at)samurai(dot)com>
To: pgsql-patches <pgsql-patches(at)postgresql(dot)org>
Subject: resetStringInfo
Date: 2007-03-03 07:00:26
Message-ID: 1172905226.6571.29.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Attached is a patch that makes a minor addition to the StringInfo API:
resetStringInfo(), which clears the current content of the StringInfo
but leaves it valid for future operations.

I needed this for an external project, but ISTM this would be worth
including in mainline: I'd imagine it's a fairly common operation, and
there's no easy way to do it at the moment. Clients can manually reset
the StringInfo's fields, but that is poor interface design, as well as
being error-prone: many people might just reset "len" and forget to
NUL-terminate the data buffer and reset the cursor. initStringInfo()
could be used, but it reallocates the StringInfo's data buffer, which is
often undesirable.

-Neil

Attachment Content-Type Size
reset_string_info-1.patch text/x-patch 1.8 KB

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Martijn van Oosterhout 2007-03-03 13:14:57 Re: Arrays of Complex Types
Previous Message Chris Marcellino 2007-03-03 04:28:58 Re: POSIX shared memory support