ISTM that PQExpBuffer is partially a memory leak. Something should need to be freed?

I copied that pattern from somewhere else, so yeah, I duplicated whatever
leak was there.

Hmmm. Indeed some commands do not free, but there is a single use and the commands exits afterwards, eg "createuser".

I think that you could use another pattern where you init the PQExpBufferData structure instead of create it, so that only the string is malloced.

I think that you should use appendPQExpBufferChar and Str instead of
relying on the format variant which is probably expensive. Something like:

  if (num_options > 0)
    append...Char(buf, ' ');
  append...Str(buf, ...);

All flavors of appendPQExpBuffer*() I can find have a const *char format string, so no way to append a naked string. If you know differently, I'm listening. Not fixed.

These prototypes are from "pqexpbuffer.h", and do not seem to rely on a format:

 extern void appendPQExpBufferChar(PQExpBuffer str, char ch);
 extern void appendPQExpBufferStr(PQExpBuffer str, const char *data);

--
Fabien


--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to