Re: resetStringInfo

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Neil Conway <neilc(at)samurai(dot)com>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, pgsql-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: resetStringInfo
Date: 2007-03-03 18:04:32
Message-ID: 20070303180432.GC6473@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Neil Conway wrote:
> On Sat, 2007-03-03 at 11:23 -0500, Bruce Momjian wrote:
> > Are there any places in our code where we could use it?
>
> I manually grep'ed around and found a few places where resetStringInfo
> can be used, but I probably didn't find them all: it's quite hard to
> find all the places in which "StringInfo->len = 0" is assigned to, given
> that the StringInfo might have any variable name, and variables like
> "len" and "buf" are very common for other purposes.

I think this is the reason why struct members are prefixed with some
short form of the struct name; for example struct timeval has tv_sec and
tv_usec. This is used in a lot of places in our code. Maybe it would
be a good idea to make it a coding guideline. For example, I'd rename
StringInfo members as si_len, si_buf, si_data, which would make this job
quite a lot easier.

(Yes, the patch would be big, but it's easy to do, if a bit tedious
because you just rename the struct and the obvious places, and then let
the compiler catch the rest.)

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2007-03-03 18:49:32 Re: Deadlock with pg_dump?
Previous Message Tom Lane 2007-03-03 17:58:11 Re: resetStringInfo