Re: [INTERFACES] ECPG: FETCH ALL|n FROM cursor - Memory allocation?

From: Christof Petig <christof(at)petig-baender(dot)de>
To: Michael Meskes <meskes(at)postgresql(dot)org>
Cc: Lee Kindness <lkindness(at)csl(dot)co(dot)uk>, PostgreSQL Interfaces <pgsql-interfaces(at)postgresql(dot)org>, Mark Aves <maves(at)csl(dot)co(dot)uk>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [INTERFACES] ECPG: FETCH ALL|n FROM cursor - Memory allocation?
Date: 2002-05-06 07:37:18
Message-ID: 3CD632AE.30000@petig-baender.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-interfaces

Michael Meskes wrote:
> On Thu, Apr 25, 2002 at 12:42:00PM +0100, Lee Kindness wrote:
>>Should the input pointers be NULL initialised? How should the memory
>>be freed?
>
>
> A simple free() will do. You also can free all automatically
> allocated memory from the most recent executed statement by calling
> ECPGfree_auto_mem(). But this is not documented and will never be.
>
> The correct way is to free(array1) and free(array2) while libecpg will
> free the internal structures when the next statement is executed.

Never, never mix these two! ECPGfree_auto_mem will free even memory
which has already been free'd by the user, perhaps we should get rid of
this method (any allocated memory regions are stored in a list, if you
never call ECPGfree_auto_mem, this list grows and grows).

Christof

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Christof Petig 2002-05-06 07:49:01 Re: HEADS UP: Win32/OS2/BeOS native ports
Previous Message Thomas Lockhart 2002-05-06 06:19:45 Re: Musings

Browse pgsql-interfaces by date

  From Date Subject
Next Message Kenny Carruthers 2002-05-06 07:53:47 Using C functions with triggers
Previous Message Frank Finner 2002-05-05 19:52:14 Re: [ERROR] pgsql_perl5