pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: tomas@mamma.varadinet.de
To: Robert A. Knop Jr. <rknop@lilys.lbl.gov>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: libpq & freeing character results
Date: Tue, 27 Jun 2000 22:20:49 +0200
Message-ID: <20000627222049.A32274@mail.aura.de> (raw)
In-Reply-To: <Pine.LNX.4.10.10006271204130.1921-100000@lilys.lbl.gov>
References: <Pine.LNX.4.10.10006271204130.1921-100000@lilys.lbl.gov>

On Tue, Jun 27, 2000 at 12:06:44PM -0700, Robert A. Knop Jr. wrote:
> If one uses libpq functions such as PQfname, should one free the returned
> character string?
> 
[...]
> This is explicitly answered in the documentation for PQgetvalue (it's a
> pointer into the PGresult data), so I'm assuming thatt he same applies for
> PQfname.  Please let me know if this is a foolish assumption.
> 
It does correspond to the general style of the interface -- and peeking
into the implementation...

======================================================================
      /*
         returns NULL if the field_num is invalid
      */
      char *
      PQfname(PGresult *res, int field_num)
      {
              if (!check_field_number("PQfname", res, field_num))
                      return NULL;
              if (res->attDescs)
                      return res->attDescs[field_num].name;
              else
                      return NULL;
      }
======================================================================
(from src/interfaces/libpq/fe-exec.c; it's version 6.5.3, but I don't
think it has changed) confirms the conjecture.

Regards
-- 
tomas



view thread (3+ messages)  latest in thread

Message-ID: <20000627222049.A32274@mail.aura.de>
Permalink:  ../20000627222049.A32274@mail.aura.de/
Also on:    postgresql.org/message-id/20000627222049.A32274@mail.aura.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: tomas@mamma.varadinet.de, rknop@lilys.lbl.gov
  Subject: Re: libpq & freeing character results
  In-Reply-To: <20000627222049.A32274@mail.aura.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox