Received: from mamma.varadinet.de (varadinet.de [193.141.160.202]) by hub.org (8.10.1/8.10.1) with ESMTP id e5RKJk159920 for ; Tue, 27 Jun 2000 16:19:46 -0400 (EDT) Received: by mamma.varadinet.de (Postfix, from userid 501) id D0854D388E; Tue, 27 Jun 2000 22:20:49 +0200 (CEST) Date: Tue, 27 Jun 2000 22:20:49 +0200 From: tomas@mamma.varadinet.de To: "Robert A. Knop Jr." Cc: pgsql-interfaces@postgresql.org Subject: Re: libpq & freeing character results Message-ID: <20000627222049.A32274@mail.aura.de> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii User-Agent: Mutt/1.0.1i In-Reply-To: ; from rknop@lilys.lbl.gov on Tue, Jun 27, 2000 at 12:06:44PM -0700 X-Archive-Number: 200007/4 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