Re: libpq & freeing character results

From: tomas(at)mamma(dot)varadinet(dot)de
To: "Robert A(dot) Knop Jr(dot)" <rknop(at)lilys(dot)lbl(dot)gov>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: libpq & freeing character results
Date: 2000-06-27 20:20:49
Message-ID: 20000627222049.A32274@mail.aura.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

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

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message Tom Lane 2000-06-27 21:36:57 Re: libpq & freeing character results
Previous Message Robert A. Knop Jr. 2000-06-27 19:06:44 libpq & freeing character results